babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4329. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4500. static readonly GEQUAL: number;
  4501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/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: Nullable<HTMLCanvasElement>;
  6354. /** @hidden */
  6355. _workingContext: Nullable<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: Nullable<BaseTexture>;
  6398. /** @hidden */
  6399. _lodTextureMid: Nullable<BaseTexture>;
  6400. /** @hidden */
  6401. _lodTextureLow: Nullable<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: Nullable<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: Nullable<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: Nullable<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 new 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: Nullable<(effect: Effect) => void>;
  22250. /**
  22251. * Callback triggered when an error occurs
  22252. */
  22253. onError: Nullable<(effect: Effect, errors: string) => void>;
  22254. /**
  22255. * Callback triggered to get the render target textures
  22256. */
  22257. getRenderTargetTextures: Nullable<() => 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: Nullable<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: Nullable<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: Nullable<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: Nullable<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. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24963. * This means the mesh underlying bounding box and sphere are recomputed.
  24964. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24965. * @returns the current mesh
  24966. */
  24967. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24968. /** @hidden */
  24969. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24970. /** @hidden */
  24971. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24972. /** @hidden */
  24973. _updateBoundingInfo(): AbstractMesh;
  24974. /** @hidden */
  24975. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24976. /** @hidden */
  24977. protected _afterComputeWorldMatrix(): void;
  24978. /** @hidden */
  24979. readonly _effectiveMesh: AbstractMesh;
  24980. /**
  24981. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24982. * A mesh is in the frustum if its bounding box intersects the frustum
  24983. * @param frustumPlanes defines the frustum to test
  24984. * @returns true if the mesh is in the frustum planes
  24985. */
  24986. isInFrustum(frustumPlanes: Plane[]): boolean;
  24987. /**
  24988. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24989. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24990. * @param frustumPlanes defines the frustum to test
  24991. * @returns true if the mesh is completely in the frustum planes
  24992. */
  24993. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24994. /**
  24995. * True if the mesh intersects another mesh or a SolidParticle object
  24996. * @param mesh defines a target mesh or SolidParticle to test
  24997. * @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)
  24998. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24999. * @returns true if there is an intersection
  25000. */
  25001. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25002. /**
  25003. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25004. * @param point defines the point to test
  25005. * @returns true if there is an intersection
  25006. */
  25007. intersectsPoint(point: Vector3): boolean;
  25008. /**
  25009. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25010. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25011. */
  25012. checkCollisions: boolean;
  25013. /**
  25014. * Gets Collider object used to compute collisions (not physics)
  25015. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25016. */
  25017. readonly collider: Nullable<Collider>;
  25018. /**
  25019. * Move the mesh using collision engine
  25020. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25021. * @param displacement defines the requested displacement vector
  25022. * @returns the current mesh
  25023. */
  25024. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25025. private _onCollisionPositionChange;
  25026. /** @hidden */
  25027. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25028. /** @hidden */
  25029. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25030. /** @hidden */
  25031. _checkCollision(collider: Collider): AbstractMesh;
  25032. /** @hidden */
  25033. _generatePointsArray(): boolean;
  25034. /**
  25035. * Checks if the passed Ray intersects with the mesh
  25036. * @param ray defines the ray to use
  25037. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25038. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25039. * @returns the picking info
  25040. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25041. */
  25042. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25043. /**
  25044. * Clones the current mesh
  25045. * @param name defines the mesh name
  25046. * @param newParent defines the new mesh parent
  25047. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25048. * @returns the new mesh
  25049. */
  25050. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25051. /**
  25052. * Disposes all the submeshes of the current meshnp
  25053. * @returns the current mesh
  25054. */
  25055. releaseSubMeshes(): AbstractMesh;
  25056. /**
  25057. * Releases resources associated with this abstract mesh.
  25058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25060. */
  25061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25062. /**
  25063. * Adds the passed mesh as a child to the current mesh
  25064. * @param mesh defines the child mesh
  25065. * @returns the current mesh
  25066. */
  25067. addChild(mesh: AbstractMesh): AbstractMesh;
  25068. /**
  25069. * Removes the passed mesh from the current mesh children list
  25070. * @param mesh defines the child mesh
  25071. * @returns the current mesh
  25072. */
  25073. removeChild(mesh: AbstractMesh): AbstractMesh;
  25074. /** @hidden */
  25075. private _initFacetData;
  25076. /**
  25077. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25078. * This method can be called within the render loop.
  25079. * 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
  25080. * @returns the current mesh
  25081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25082. */
  25083. updateFacetData(): AbstractMesh;
  25084. /**
  25085. * Returns the facetLocalNormals array.
  25086. * The normals are expressed in the mesh local spac
  25087. * @returns an array of Vector3
  25088. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25089. */
  25090. getFacetLocalNormals(): Vector3[];
  25091. /**
  25092. * Returns the facetLocalPositions array.
  25093. * The facet positions are expressed in the mesh local space
  25094. * @returns an array of Vector3
  25095. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25096. */
  25097. getFacetLocalPositions(): Vector3[];
  25098. /**
  25099. * Returns the facetLocalPartioning array
  25100. * @returns an array of array of numbers
  25101. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25102. */
  25103. getFacetLocalPartitioning(): number[][];
  25104. /**
  25105. * Returns the i-th facet position in the world system.
  25106. * This method allocates a new Vector3 per call
  25107. * @param i defines the facet index
  25108. * @returns a new Vector3
  25109. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25110. */
  25111. getFacetPosition(i: number): Vector3;
  25112. /**
  25113. * Sets the reference Vector3 with the i-th facet position in the world system
  25114. * @param i defines the facet index
  25115. * @param ref defines the target vector
  25116. * @returns the current mesh
  25117. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25118. */
  25119. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25120. /**
  25121. * Returns the i-th facet normal in the world system.
  25122. * This method allocates a new Vector3 per call
  25123. * @param i defines the facet index
  25124. * @returns a new Vector3
  25125. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25126. */
  25127. getFacetNormal(i: number): Vector3;
  25128. /**
  25129. * Sets the reference Vector3 with the i-th facet normal in the world system
  25130. * @param i defines the facet index
  25131. * @param ref defines the target vector
  25132. * @returns the current mesh
  25133. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25134. */
  25135. getFacetNormalToRef(i: number, ref: Vector3): this;
  25136. /**
  25137. * 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)
  25138. * @param x defines x coordinate
  25139. * @param y defines y coordinate
  25140. * @param z defines z coordinate
  25141. * @returns the array of facet indexes
  25142. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25143. */
  25144. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25145. /**
  25146. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25147. * @param projected sets as the (x,y,z) world projection on the facet
  25148. * @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
  25149. * @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
  25150. * @param x defines x coordinate
  25151. * @param y defines y coordinate
  25152. * @param z defines z coordinate
  25153. * @returns the face index if found (or null instead)
  25154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25155. */
  25156. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25157. /**
  25158. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25159. * @param projected sets as the (x,y,z) local projection on the facet
  25160. * @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
  25161. * @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
  25162. * @param x defines x coordinate
  25163. * @param y defines y coordinate
  25164. * @param z defines z coordinate
  25165. * @returns the face index if found (or null instead)
  25166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25167. */
  25168. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25169. /**
  25170. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25171. * @returns the parameters
  25172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25173. */
  25174. getFacetDataParameters(): any;
  25175. /**
  25176. * Disables the feature FacetData and frees the related memory
  25177. * @returns the current mesh
  25178. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25179. */
  25180. disableFacetData(): AbstractMesh;
  25181. /**
  25182. * Updates the AbstractMesh indices array
  25183. * @param indices defines the data source
  25184. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25185. * @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)
  25186. * @returns the current mesh
  25187. */
  25188. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25189. /**
  25190. * Creates new normals data for the mesh
  25191. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25192. * @returns the current mesh
  25193. */
  25194. createNormals(updatable: boolean): AbstractMesh;
  25195. /**
  25196. * Align the mesh with a normal
  25197. * @param normal defines the normal to use
  25198. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25199. * @returns the current mesh
  25200. */
  25201. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25202. /** @hidden */
  25203. _checkOcclusionQuery(): boolean;
  25204. }
  25205. }
  25206. declare module "babylonjs/Actions/actionEvent" {
  25207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25208. import { Nullable } from "babylonjs/types";
  25209. import { Sprite } from "babylonjs/Sprites/sprite";
  25210. import { Scene } from "babylonjs/scene";
  25211. import { Vector2 } from "babylonjs/Maths/math";
  25212. /**
  25213. * Interface used to define ActionEvent
  25214. */
  25215. export interface IActionEvent {
  25216. /** The mesh or sprite that triggered the action */
  25217. source: any;
  25218. /** The X mouse cursor position at the time of the event */
  25219. pointerX: number;
  25220. /** The Y mouse cursor position at the time of the event */
  25221. pointerY: number;
  25222. /** The mesh that is currently pointed at (can be null) */
  25223. meshUnderPointer: Nullable<AbstractMesh>;
  25224. /** the original (browser) event that triggered the ActionEvent */
  25225. sourceEvent?: any;
  25226. /** additional data for the event */
  25227. additionalData?: any;
  25228. }
  25229. /**
  25230. * ActionEvent is the event being sent when an action is triggered.
  25231. */
  25232. export class ActionEvent implements IActionEvent {
  25233. /** The mesh or sprite that triggered the action */
  25234. source: any;
  25235. /** The X mouse cursor position at the time of the event */
  25236. pointerX: number;
  25237. /** The Y mouse cursor position at the time of the event */
  25238. pointerY: number;
  25239. /** The mesh that is currently pointed at (can be null) */
  25240. meshUnderPointer: Nullable<AbstractMesh>;
  25241. /** the original (browser) event that triggered the ActionEvent */
  25242. sourceEvent?: any;
  25243. /** additional data for the event */
  25244. additionalData?: any;
  25245. /**
  25246. * Creates a new ActionEvent
  25247. * @param source The mesh or sprite that triggered the action
  25248. * @param pointerX The X mouse cursor position at the time of the event
  25249. * @param pointerY The Y mouse cursor position at the time of the event
  25250. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25251. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25252. * @param additionalData additional data for the event
  25253. */
  25254. constructor(
  25255. /** The mesh or sprite that triggered the action */
  25256. source: any,
  25257. /** The X mouse cursor position at the time of the event */
  25258. pointerX: number,
  25259. /** The Y mouse cursor position at the time of the event */
  25260. pointerY: number,
  25261. /** The mesh that is currently pointed at (can be null) */
  25262. meshUnderPointer: Nullable<AbstractMesh>,
  25263. /** the original (browser) event that triggered the ActionEvent */
  25264. sourceEvent?: any,
  25265. /** additional data for the event */
  25266. additionalData?: any);
  25267. /**
  25268. * Helper function to auto-create an ActionEvent from a source mesh.
  25269. * @param source The source mesh that triggered the event
  25270. * @param evt The original (browser) event
  25271. * @param additionalData additional data for the event
  25272. * @returns the new ActionEvent
  25273. */
  25274. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25275. /**
  25276. * Helper function to auto-create an ActionEvent from a source sprite
  25277. * @param source The source sprite that triggered the event
  25278. * @param scene Scene associated with the sprite
  25279. * @param evt The original (browser) event
  25280. * @param additionalData additional data for the event
  25281. * @returns the new ActionEvent
  25282. */
  25283. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25284. /**
  25285. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25286. * @param scene the scene where the event occurred
  25287. * @param evt The original (browser) event
  25288. * @returns the new ActionEvent
  25289. */
  25290. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25291. /**
  25292. * Helper function to auto-create an ActionEvent from a primitive
  25293. * @param prim defines the target primitive
  25294. * @param pointerPos defines the pointer position
  25295. * @param evt The original (browser) event
  25296. * @param additionalData additional data for the event
  25297. * @returns the new ActionEvent
  25298. */
  25299. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25300. }
  25301. }
  25302. declare module "babylonjs/Actions/abstractActionManager" {
  25303. import { IDisposable } from "babylonjs/scene";
  25304. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25305. import { IAction } from "babylonjs/Actions/action";
  25306. import { Nullable } from "babylonjs/types";
  25307. /**
  25308. * Abstract class used to decouple action Manager from scene and meshes.
  25309. * Do not instantiate.
  25310. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25311. */
  25312. export abstract class AbstractActionManager implements IDisposable {
  25313. /** Gets the list of active triggers */
  25314. static Triggers: {
  25315. [key: string]: number;
  25316. };
  25317. /** Gets the cursor to use when hovering items */
  25318. hoverCursor: string;
  25319. /** Gets the list of actions */
  25320. actions: IAction[];
  25321. /**
  25322. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25323. */
  25324. isRecursive: boolean;
  25325. /**
  25326. * Releases all associated resources
  25327. */
  25328. abstract dispose(): void;
  25329. /**
  25330. * Does this action manager has pointer triggers
  25331. */
  25332. abstract readonly hasPointerTriggers: boolean;
  25333. /**
  25334. * Does this action manager has pick triggers
  25335. */
  25336. abstract readonly hasPickTriggers: boolean;
  25337. /**
  25338. * Process a specific trigger
  25339. * @param trigger defines the trigger to process
  25340. * @param evt defines the event details to be processed
  25341. */
  25342. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25343. /**
  25344. * Does this action manager handles actions of any of the given triggers
  25345. * @param triggers defines the triggers to be tested
  25346. * @return a boolean indicating whether one (or more) of the triggers is handled
  25347. */
  25348. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25349. /**
  25350. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25351. * speed.
  25352. * @param triggerA defines the trigger to be tested
  25353. * @param triggerB defines the trigger to be tested
  25354. * @return a boolean indicating whether one (or more) of the triggers is handled
  25355. */
  25356. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25357. /**
  25358. * Does this action manager handles actions of a given trigger
  25359. * @param trigger defines the trigger to be tested
  25360. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25361. * @return whether the trigger is handled
  25362. */
  25363. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25364. /**
  25365. * Serialize this manager to a JSON object
  25366. * @param name defines the property name to store this manager
  25367. * @returns a JSON representation of this manager
  25368. */
  25369. abstract serialize(name: string): any;
  25370. /**
  25371. * Registers an action to this action manager
  25372. * @param action defines the action to be registered
  25373. * @return the action amended (prepared) after registration
  25374. */
  25375. abstract registerAction(action: IAction): Nullable<IAction>;
  25376. /**
  25377. * Unregisters an action to this action manager
  25378. * @param action defines the action to be unregistered
  25379. * @return a boolean indicating whether the action has been unregistered
  25380. */
  25381. abstract unregisterAction(action: IAction): Boolean;
  25382. /**
  25383. * Does exist one action manager with at least one trigger
  25384. **/
  25385. static readonly HasTriggers: boolean;
  25386. /**
  25387. * Does exist one action manager with at least one pick trigger
  25388. **/
  25389. static readonly HasPickTriggers: boolean;
  25390. /**
  25391. * Does exist one action manager that handles actions of a given trigger
  25392. * @param trigger defines the trigger to be tested
  25393. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25394. **/
  25395. static HasSpecificTrigger(trigger: number): boolean;
  25396. }
  25397. }
  25398. declare module "babylonjs/node" {
  25399. import { Scene } from "babylonjs/scene";
  25400. import { Nullable } from "babylonjs/types";
  25401. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25402. import { Engine } from "babylonjs/Engines/engine";
  25403. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25404. import { Observable } from "babylonjs/Misc/observable";
  25405. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25406. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25407. import { Animatable } from "babylonjs/Animations/animatable";
  25408. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25409. import { Animation } from "babylonjs/Animations/animation";
  25410. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25412. /**
  25413. * Defines how a node can be built from a string name.
  25414. */
  25415. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25416. /**
  25417. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25418. */
  25419. export class Node implements IBehaviorAware<Node> {
  25420. /** @hidden */
  25421. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25422. private static _NodeConstructors;
  25423. /**
  25424. * Add a new node constructor
  25425. * @param type defines the type name of the node to construct
  25426. * @param constructorFunc defines the constructor function
  25427. */
  25428. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25429. /**
  25430. * Returns a node constructor based on type name
  25431. * @param type defines the type name
  25432. * @param name defines the new node name
  25433. * @param scene defines the hosting scene
  25434. * @param options defines optional options to transmit to constructors
  25435. * @returns the new constructor or null
  25436. */
  25437. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25438. /**
  25439. * Gets or sets the name of the node
  25440. */
  25441. name: string;
  25442. /**
  25443. * Gets or sets the id of the node
  25444. */
  25445. id: string;
  25446. /**
  25447. * Gets or sets the unique id of the node
  25448. */
  25449. uniqueId: number;
  25450. /**
  25451. * Gets or sets a string used to store user defined state for the node
  25452. */
  25453. state: string;
  25454. /**
  25455. * Gets or sets an object used to store user defined information for the node
  25456. */
  25457. metadata: any;
  25458. /**
  25459. * For internal use only. Please do not use.
  25460. */
  25461. reservedDataStore: any;
  25462. /**
  25463. * List of inspectable custom properties (used by the Inspector)
  25464. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25465. */
  25466. inspectableCustomProperties: IInspectable[];
  25467. /**
  25468. * Gets or sets a boolean used to define if the node must be serialized
  25469. */
  25470. doNotSerialize: boolean;
  25471. /** @hidden */
  25472. _isDisposed: boolean;
  25473. /**
  25474. * Gets a list of Animations associated with the node
  25475. */
  25476. animations: import("babylonjs/Animations/animation").Animation[];
  25477. protected _ranges: {
  25478. [name: string]: Nullable<AnimationRange>;
  25479. };
  25480. /**
  25481. * Callback raised when the node is ready to be used
  25482. */
  25483. onReady: Nullable<(node: Node) => void>;
  25484. private _isEnabled;
  25485. private _isParentEnabled;
  25486. private _isReady;
  25487. /** @hidden */
  25488. _currentRenderId: number;
  25489. private _parentUpdateId;
  25490. /** @hidden */
  25491. _childUpdateId: number;
  25492. /** @hidden */
  25493. _waitingParentId: Nullable<string>;
  25494. /** @hidden */
  25495. _scene: Scene;
  25496. /** @hidden */
  25497. _cache: any;
  25498. private _parentNode;
  25499. private _children;
  25500. /** @hidden */
  25501. _worldMatrix: Matrix;
  25502. /** @hidden */
  25503. _worldMatrixDeterminant: number;
  25504. /** @hidden */
  25505. _worldMatrixDeterminantIsDirty: boolean;
  25506. /** @hidden */
  25507. private _sceneRootNodesIndex;
  25508. /**
  25509. * Gets a boolean indicating if the node has been disposed
  25510. * @returns true if the node was disposed
  25511. */
  25512. isDisposed(): boolean;
  25513. /**
  25514. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25515. * @see https://doc.babylonjs.com/how_to/parenting
  25516. */
  25517. parent: Nullable<Node>;
  25518. private addToSceneRootNodes;
  25519. private removeFromSceneRootNodes;
  25520. private _animationPropertiesOverride;
  25521. /**
  25522. * Gets or sets the animation properties override
  25523. */
  25524. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25525. /**
  25526. * Gets a string idenfifying the name of the class
  25527. * @returns "Node" string
  25528. */
  25529. getClassName(): string;
  25530. /** @hidden */
  25531. readonly _isNode: boolean;
  25532. /**
  25533. * An event triggered when the mesh is disposed
  25534. */
  25535. onDisposeObservable: Observable<Node>;
  25536. private _onDisposeObserver;
  25537. /**
  25538. * Sets a callback that will be raised when the node will be disposed
  25539. */
  25540. onDispose: () => void;
  25541. /**
  25542. * Creates a new Node
  25543. * @param name the name and id to be given to this node
  25544. * @param scene the scene this node will be added to
  25545. * @param addToRootNodes the node will be added to scene.rootNodes
  25546. */
  25547. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25548. /**
  25549. * Gets the scene of the node
  25550. * @returns a scene
  25551. */
  25552. getScene(): Scene;
  25553. /**
  25554. * Gets the engine of the node
  25555. * @returns a Engine
  25556. */
  25557. getEngine(): Engine;
  25558. private _behaviors;
  25559. /**
  25560. * Attach a behavior to the node
  25561. * @see http://doc.babylonjs.com/features/behaviour
  25562. * @param behavior defines the behavior to attach
  25563. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25564. * @returns the current Node
  25565. */
  25566. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25567. /**
  25568. * Remove an attached behavior
  25569. * @see http://doc.babylonjs.com/features/behaviour
  25570. * @param behavior defines the behavior to attach
  25571. * @returns the current Node
  25572. */
  25573. removeBehavior(behavior: Behavior<Node>): Node;
  25574. /**
  25575. * Gets the list of attached behaviors
  25576. * @see http://doc.babylonjs.com/features/behaviour
  25577. */
  25578. readonly behaviors: Behavior<Node>[];
  25579. /**
  25580. * Gets an attached behavior by name
  25581. * @param name defines the name of the behavior to look for
  25582. * @see http://doc.babylonjs.com/features/behaviour
  25583. * @returns null if behavior was not found else the requested behavior
  25584. */
  25585. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25586. /**
  25587. * Returns the latest update of the World matrix
  25588. * @returns a Matrix
  25589. */
  25590. getWorldMatrix(): Matrix;
  25591. /** @hidden */
  25592. _getWorldMatrixDeterminant(): number;
  25593. /**
  25594. * Returns directly the latest state of the mesh World matrix.
  25595. * A Matrix is returned.
  25596. */
  25597. readonly worldMatrixFromCache: Matrix;
  25598. /** @hidden */
  25599. _initCache(): void;
  25600. /** @hidden */
  25601. updateCache(force?: boolean): void;
  25602. /** @hidden */
  25603. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25604. /** @hidden */
  25605. _updateCache(ignoreParentClass?: boolean): void;
  25606. /** @hidden */
  25607. _isSynchronized(): boolean;
  25608. /** @hidden */
  25609. _markSyncedWithParent(): void;
  25610. /** @hidden */
  25611. isSynchronizedWithParent(): boolean;
  25612. /** @hidden */
  25613. isSynchronized(): boolean;
  25614. /**
  25615. * Is this node ready to be used/rendered
  25616. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25617. * @return true if the node is ready
  25618. */
  25619. isReady(completeCheck?: boolean): boolean;
  25620. /**
  25621. * Is this node enabled?
  25622. * 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
  25623. * @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
  25624. * @return whether this node (and its parent) is enabled
  25625. */
  25626. isEnabled(checkAncestors?: boolean): boolean;
  25627. /** @hidden */
  25628. protected _syncParentEnabledState(): void;
  25629. /**
  25630. * Set the enabled state of this node
  25631. * @param value defines the new enabled state
  25632. */
  25633. setEnabled(value: boolean): void;
  25634. /**
  25635. * Is this node a descendant of the given node?
  25636. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25637. * @param ancestor defines the parent node to inspect
  25638. * @returns a boolean indicating if this node is a descendant of the given node
  25639. */
  25640. isDescendantOf(ancestor: Node): boolean;
  25641. /** @hidden */
  25642. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25643. /**
  25644. * Will return all nodes that have this node as ascendant
  25645. * @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
  25646. * @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
  25647. * @return all children nodes of all types
  25648. */
  25649. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25650. /**
  25651. * Get all child-meshes of this node
  25652. * @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)
  25653. * @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
  25654. * @returns an array of AbstractMesh
  25655. */
  25656. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25657. /**
  25658. * Get all direct children of this node
  25659. * @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
  25660. * @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)
  25661. * @returns an array of Node
  25662. */
  25663. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25664. /** @hidden */
  25665. _setReady(state: boolean): void;
  25666. /**
  25667. * Get an animation by name
  25668. * @param name defines the name of the animation to look for
  25669. * @returns null if not found else the requested animation
  25670. */
  25671. getAnimationByName(name: string): Nullable<Animation>;
  25672. /**
  25673. * Creates an animation range for this node
  25674. * @param name defines the name of the range
  25675. * @param from defines the starting key
  25676. * @param to defines the end key
  25677. */
  25678. createAnimationRange(name: string, from: number, to: number): void;
  25679. /**
  25680. * Delete a specific animation range
  25681. * @param name defines the name of the range to delete
  25682. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25683. */
  25684. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25685. /**
  25686. * Get an animation range by name
  25687. * @param name defines the name of the animation range to look for
  25688. * @returns null if not found else the requested animation range
  25689. */
  25690. getAnimationRange(name: string): Nullable<AnimationRange>;
  25691. /**
  25692. * Gets the list of all animation ranges defined on this node
  25693. * @returns an array
  25694. */
  25695. getAnimationRanges(): Nullable<AnimationRange>[];
  25696. /**
  25697. * Will start the animation sequence
  25698. * @param name defines the range frames for animation sequence
  25699. * @param loop defines if the animation should loop (false by default)
  25700. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25701. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25702. * @returns the object created for this animation. If range does not exist, it will return null
  25703. */
  25704. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25705. /**
  25706. * Serialize animation ranges into a JSON compatible object
  25707. * @returns serialization object
  25708. */
  25709. serializeAnimationRanges(): any;
  25710. /**
  25711. * Computes the world matrix of the node
  25712. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25713. * @returns the world matrix
  25714. */
  25715. computeWorldMatrix(force?: boolean): Matrix;
  25716. /**
  25717. * Releases resources associated with this node.
  25718. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25719. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25720. */
  25721. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25722. /**
  25723. * Parse animation range data from a serialization object and store them into a given node
  25724. * @param node defines where to store the animation ranges
  25725. * @param parsedNode defines the serialization object to read data from
  25726. * @param scene defines the hosting scene
  25727. */
  25728. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25729. /**
  25730. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25731. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25732. * @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
  25733. * @returns the new bounding vectors
  25734. */
  25735. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25736. min: Vector3;
  25737. max: Vector3;
  25738. };
  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?: Nullable<(effect: Effect) => void>, onError?: Nullable<(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: Nullable<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. /**
  43835. * Mesh used as a pivot to rotate the attached mesh
  43836. */
  43837. private _anchorMesh;
  43838. private _existingMeshScale;
  43839. private _dragMesh;
  43840. private pointerDragBehavior;
  43841. private coloredMaterial;
  43842. private hoverColoredMaterial;
  43843. /**
  43844. * Sets the color of the bounding box gizmo
  43845. * @param color the color to set
  43846. */
  43847. setColor(color: Color3): void;
  43848. /**
  43849. * Creates an BoundingBoxGizmo
  43850. * @param gizmoLayer The utility layer the gizmo will be added to
  43851. * @param color The color of the gizmo
  43852. */
  43853. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43854. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43855. private _selectNode;
  43856. /**
  43857. * Updates the bounding box information for the Gizmo
  43858. */
  43859. updateBoundingBox(): void;
  43860. private _updateRotationSpheres;
  43861. private _updateScaleBoxes;
  43862. /**
  43863. * Enables rotation on the specified axis and disables rotation on the others
  43864. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43865. */
  43866. setEnabledRotationAxis(axis: string): void;
  43867. /**
  43868. * Enables/disables scaling
  43869. * @param enable if scaling should be enabled
  43870. */
  43871. setEnabledScaling(enable: boolean): void;
  43872. private _updateDummy;
  43873. /**
  43874. * Enables a pointer drag behavior on the bounding box of the gizmo
  43875. */
  43876. enableDragBehavior(): void;
  43877. /**
  43878. * Disposes of the gizmo
  43879. */
  43880. dispose(): void;
  43881. /**
  43882. * 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)
  43883. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43884. * @returns the bounding box mesh with the passed in mesh as a child
  43885. */
  43886. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43887. /**
  43888. * CustomMeshes are not supported by this gizmo
  43889. * @param mesh The mesh to replace the default mesh of the gizmo
  43890. */
  43891. setCustomMesh(mesh: Mesh): void;
  43892. }
  43893. }
  43894. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43895. import { Observable } from "babylonjs/Misc/observable";
  43896. import { Nullable } from "babylonjs/types";
  43897. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43899. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43900. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43901. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43902. import "babylonjs/Meshes/Builders/linesBuilder";
  43903. /**
  43904. * Single plane rotation gizmo
  43905. */
  43906. export class PlaneRotationGizmo extends Gizmo {
  43907. /**
  43908. * Drag behavior responsible for the gizmos dragging interactions
  43909. */
  43910. dragBehavior: PointerDragBehavior;
  43911. private _pointerObserver;
  43912. /**
  43913. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43914. */
  43915. snapDistance: number;
  43916. /**
  43917. * Event that fires each time the gizmo snaps to a new location.
  43918. * * snapDistance is the the change in distance
  43919. */
  43920. onSnapObservable: Observable<{
  43921. snapDistance: number;
  43922. }>;
  43923. /**
  43924. * Creates a PlaneRotationGizmo
  43925. * @param gizmoLayer The utility layer the gizmo will be added to
  43926. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43927. * @param color The color of the gizmo
  43928. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43929. */
  43930. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43931. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43932. /**
  43933. * Disposes of the gizmo
  43934. */
  43935. dispose(): void;
  43936. }
  43937. }
  43938. declare module "babylonjs/Gizmos/rotationGizmo" {
  43939. import { Observable } from "babylonjs/Misc/observable";
  43940. import { Nullable } from "babylonjs/types";
  43941. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43942. import { Mesh } from "babylonjs/Meshes/mesh";
  43943. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43944. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  43945. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43946. /**
  43947. * Gizmo that enables rotating a mesh along 3 axis
  43948. */
  43949. export class RotationGizmo extends Gizmo {
  43950. /**
  43951. * Internal gizmo used for interactions on the x axis
  43952. */
  43953. xGizmo: PlaneRotationGizmo;
  43954. /**
  43955. * Internal gizmo used for interactions on the y axis
  43956. */
  43957. yGizmo: PlaneRotationGizmo;
  43958. /**
  43959. * Internal gizmo used for interactions on the z axis
  43960. */
  43961. zGizmo: PlaneRotationGizmo;
  43962. /** Fires an event when any of it's sub gizmos are dragged */
  43963. onDragStartObservable: Observable<{}>;
  43964. /** Fires an event when any of it's sub gizmos are released from dragging */
  43965. onDragEndObservable: Observable<{}>;
  43966. attachedMesh: Nullable<AbstractMesh>;
  43967. /**
  43968. * Creates a RotationGizmo
  43969. * @param gizmoLayer The utility layer the gizmo will be added to
  43970. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43971. */
  43972. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43973. updateGizmoRotationToMatchAttachedMesh: boolean;
  43974. /**
  43975. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43976. */
  43977. snapDistance: number;
  43978. /**
  43979. * Ratio for the scale of the gizmo (Default: 1)
  43980. */
  43981. scaleRatio: number;
  43982. /**
  43983. * Disposes of the gizmo
  43984. */
  43985. dispose(): void;
  43986. /**
  43987. * CustomMeshes are not supported by this gizmo
  43988. * @param mesh The mesh to replace the default mesh of the gizmo
  43989. */
  43990. setCustomMesh(mesh: Mesh): void;
  43991. }
  43992. }
  43993. declare module "babylonjs/Gizmos/positionGizmo" {
  43994. import { Observable } from "babylonjs/Misc/observable";
  43995. import { Nullable } from "babylonjs/types";
  43996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43997. import { Mesh } from "babylonjs/Meshes/mesh";
  43998. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43999. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44000. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44001. /**
  44002. * Gizmo that enables dragging a mesh along 3 axis
  44003. */
  44004. export class PositionGizmo extends Gizmo {
  44005. /**
  44006. * Internal gizmo used for interactions on the x axis
  44007. */
  44008. xGizmo: AxisDragGizmo;
  44009. /**
  44010. * Internal gizmo used for interactions on the y axis
  44011. */
  44012. yGizmo: AxisDragGizmo;
  44013. /**
  44014. * Internal gizmo used for interactions on the z axis
  44015. */
  44016. zGizmo: AxisDragGizmo;
  44017. /** Fires an event when any of it's sub gizmos are dragged */
  44018. onDragStartObservable: Observable<{}>;
  44019. /** Fires an event when any of it's sub gizmos are released from dragging */
  44020. onDragEndObservable: Observable<{}>;
  44021. attachedMesh: Nullable<AbstractMesh>;
  44022. /**
  44023. * Creates a PositionGizmo
  44024. * @param gizmoLayer The utility layer the gizmo will be added to
  44025. */
  44026. constructor(gizmoLayer?: UtilityLayerRenderer);
  44027. updateGizmoRotationToMatchAttachedMesh: boolean;
  44028. /**
  44029. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44030. */
  44031. snapDistance: number;
  44032. /**
  44033. * Ratio for the scale of the gizmo (Default: 1)
  44034. */
  44035. scaleRatio: number;
  44036. /**
  44037. * Disposes of the gizmo
  44038. */
  44039. dispose(): void;
  44040. /**
  44041. * CustomMeshes are not supported by this gizmo
  44042. * @param mesh The mesh to replace the default mesh of the gizmo
  44043. */
  44044. setCustomMesh(mesh: Mesh): void;
  44045. }
  44046. }
  44047. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44048. import { Scene } from "babylonjs/scene";
  44049. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44050. import { Mesh } from "babylonjs/Meshes/mesh";
  44051. import { Nullable } from "babylonjs/types";
  44052. /**
  44053. * Class containing static functions to help procedurally build meshes
  44054. */
  44055. export class PolyhedronBuilder {
  44056. /**
  44057. * Creates a polyhedron mesh
  44058. * * 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
  44059. * * The parameter `size` (positive float, default 1) sets the polygon size
  44060. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44061. * * 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`
  44062. * * 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
  44063. * * 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)`)
  44064. * * 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
  44065. * * 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
  44066. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44067. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44069. * @param name defines the name of the mesh
  44070. * @param options defines the options used to create the mesh
  44071. * @param scene defines the hosting scene
  44072. * @returns the polyhedron mesh
  44073. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44074. */
  44075. static CreatePolyhedron(name: string, options: {
  44076. type?: number;
  44077. size?: number;
  44078. sizeX?: number;
  44079. sizeY?: number;
  44080. sizeZ?: number;
  44081. custom?: any;
  44082. faceUV?: Vector4[];
  44083. faceColors?: Color4[];
  44084. flat?: boolean;
  44085. updatable?: boolean;
  44086. sideOrientation?: number;
  44087. frontUVs?: Vector4;
  44088. backUVs?: Vector4;
  44089. }, scene?: Nullable<Scene>): Mesh;
  44090. }
  44091. }
  44092. declare module "babylonjs/Gizmos/scaleGizmo" {
  44093. import { Observable } from "babylonjs/Misc/observable";
  44094. import { Nullable } from "babylonjs/types";
  44095. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44096. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44097. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44098. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44099. /**
  44100. * Gizmo that enables scaling a mesh along 3 axis
  44101. */
  44102. export class ScaleGizmo extends Gizmo {
  44103. /**
  44104. * Internal gizmo used for interactions on the x axis
  44105. */
  44106. xGizmo: AxisScaleGizmo;
  44107. /**
  44108. * Internal gizmo used for interactions on the y axis
  44109. */
  44110. yGizmo: AxisScaleGizmo;
  44111. /**
  44112. * Internal gizmo used for interactions on the z axis
  44113. */
  44114. zGizmo: AxisScaleGizmo;
  44115. /**
  44116. * Internal gizmo used to scale all axis equally
  44117. */
  44118. uniformScaleGizmo: AxisScaleGizmo;
  44119. /** Fires an event when any of it's sub gizmos are dragged */
  44120. onDragStartObservable: Observable<{}>;
  44121. /** Fires an event when any of it's sub gizmos are released from dragging */
  44122. onDragEndObservable: Observable<{}>;
  44123. attachedMesh: Nullable<AbstractMesh>;
  44124. /**
  44125. * Creates a ScaleGizmo
  44126. * @param gizmoLayer The utility layer the gizmo will be added to
  44127. */
  44128. constructor(gizmoLayer?: UtilityLayerRenderer);
  44129. updateGizmoRotationToMatchAttachedMesh: boolean;
  44130. /**
  44131. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44132. */
  44133. snapDistance: number;
  44134. /**
  44135. * Ratio for the scale of the gizmo (Default: 1)
  44136. */
  44137. scaleRatio: number;
  44138. /**
  44139. * Disposes of the gizmo
  44140. */
  44141. dispose(): void;
  44142. }
  44143. }
  44144. declare module "babylonjs/Gizmos/gizmoManager" {
  44145. import { Observable } from "babylonjs/Misc/observable";
  44146. import { Nullable } from "babylonjs/types";
  44147. import { Scene, IDisposable } from "babylonjs/scene";
  44148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44149. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44150. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44151. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44152. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44153. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44154. /**
  44155. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44156. */
  44157. export class GizmoManager implements IDisposable {
  44158. private scene;
  44159. /**
  44160. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44161. */
  44162. gizmos: {
  44163. positionGizmo: Nullable<PositionGizmo>;
  44164. rotationGizmo: Nullable<RotationGizmo>;
  44165. scaleGizmo: Nullable<ScaleGizmo>;
  44166. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44167. };
  44168. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44169. clearGizmoOnEmptyPointerEvent: boolean;
  44170. /** Fires an event when the manager is attached to a mesh */
  44171. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44172. private _gizmosEnabled;
  44173. private _pointerObserver;
  44174. private _attachedMesh;
  44175. private _boundingBoxColor;
  44176. private _defaultUtilityLayer;
  44177. private _defaultKeepDepthUtilityLayer;
  44178. /**
  44179. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44180. */
  44181. boundingBoxDragBehavior: SixDofDragBehavior;
  44182. /**
  44183. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44184. */
  44185. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44186. /**
  44187. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44188. */
  44189. usePointerToAttachGizmos: boolean;
  44190. /**
  44191. * Instatiates a gizmo manager
  44192. * @param scene the scene to overlay the gizmos on top of
  44193. */
  44194. constructor(scene: Scene);
  44195. /**
  44196. * Attaches a set of gizmos to the specified mesh
  44197. * @param mesh The mesh the gizmo's should be attached to
  44198. */
  44199. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44200. /**
  44201. * If the position gizmo is enabled
  44202. */
  44203. positionGizmoEnabled: boolean;
  44204. /**
  44205. * If the rotation gizmo is enabled
  44206. */
  44207. rotationGizmoEnabled: boolean;
  44208. /**
  44209. * If the scale gizmo is enabled
  44210. */
  44211. scaleGizmoEnabled: boolean;
  44212. /**
  44213. * If the boundingBox gizmo is enabled
  44214. */
  44215. boundingBoxGizmoEnabled: boolean;
  44216. /**
  44217. * Disposes of the gizmo manager
  44218. */
  44219. dispose(): void;
  44220. }
  44221. }
  44222. declare module "babylonjs/Lights/directionalLight" {
  44223. import { Camera } from "babylonjs/Cameras/camera";
  44224. import { Scene } from "babylonjs/scene";
  44225. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44226. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44227. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44228. import { Effect } from "babylonjs/Materials/effect";
  44229. /**
  44230. * A directional light is defined by a direction (what a surprise!).
  44231. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44232. * 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.
  44233. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44234. */
  44235. export class DirectionalLight extends ShadowLight {
  44236. private _shadowFrustumSize;
  44237. /**
  44238. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44239. */
  44240. /**
  44241. * Specifies a fix frustum size for the shadow generation.
  44242. */
  44243. shadowFrustumSize: number;
  44244. private _shadowOrthoScale;
  44245. /**
  44246. * Gets the shadow projection scale against the optimal computed one.
  44247. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44248. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44249. */
  44250. /**
  44251. * Sets the shadow projection scale against the optimal computed one.
  44252. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44253. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44254. */
  44255. shadowOrthoScale: number;
  44256. /**
  44257. * Automatically compute the projection matrix to best fit (including all the casters)
  44258. * on each frame.
  44259. */
  44260. autoUpdateExtends: boolean;
  44261. private _orthoLeft;
  44262. private _orthoRight;
  44263. private _orthoTop;
  44264. private _orthoBottom;
  44265. /**
  44266. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44267. * The directional light is emitted from everywhere in the given direction.
  44268. * It can cast shadows.
  44269. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44270. * @param name The friendly name of the light
  44271. * @param direction The direction of the light
  44272. * @param scene The scene the light belongs to
  44273. */
  44274. constructor(name: string, direction: Vector3, scene: Scene);
  44275. /**
  44276. * Returns the string "DirectionalLight".
  44277. * @return The class name
  44278. */
  44279. getClassName(): string;
  44280. /**
  44281. * Returns the integer 1.
  44282. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44283. */
  44284. getTypeID(): number;
  44285. /**
  44286. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44287. * Returns the DirectionalLight Shadow projection matrix.
  44288. */
  44289. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44290. /**
  44291. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44292. * Returns the DirectionalLight Shadow projection matrix.
  44293. */
  44294. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44295. /**
  44296. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44297. * Returns the DirectionalLight Shadow projection matrix.
  44298. */
  44299. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44300. protected _buildUniformLayout(): void;
  44301. /**
  44302. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44303. * @param effect The effect to update
  44304. * @param lightIndex The index of the light in the effect to update
  44305. * @returns The directional light
  44306. */
  44307. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44308. /**
  44309. * Gets the minZ used for shadow according to both the scene and the light.
  44310. *
  44311. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44312. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44313. * @param activeCamera The camera we are returning the min for
  44314. * @returns the depth min z
  44315. */
  44316. getDepthMinZ(activeCamera: Camera): number;
  44317. /**
  44318. * Gets the maxZ used for shadow according to both the scene and the light.
  44319. *
  44320. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44321. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44322. * @param activeCamera The camera we are returning the max for
  44323. * @returns the depth max z
  44324. */
  44325. getDepthMaxZ(activeCamera: Camera): number;
  44326. /**
  44327. * Prepares the list of defines specific to the light type.
  44328. * @param defines the list of defines
  44329. * @param lightIndex defines the index of the light for the effect
  44330. */
  44331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44332. }
  44333. }
  44334. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44335. import { Mesh } from "babylonjs/Meshes/mesh";
  44336. /**
  44337. * Class containing static functions to help procedurally build meshes
  44338. */
  44339. export class HemisphereBuilder {
  44340. /**
  44341. * Creates a hemisphere mesh
  44342. * @param name defines the name of the mesh
  44343. * @param options defines the options used to create the mesh
  44344. * @param scene defines the hosting scene
  44345. * @returns the hemisphere mesh
  44346. */
  44347. static CreateHemisphere(name: string, options: {
  44348. segments?: number;
  44349. diameter?: number;
  44350. sideOrientation?: number;
  44351. }, scene: any): Mesh;
  44352. }
  44353. }
  44354. declare module "babylonjs/Lights/spotLight" {
  44355. import { Nullable } from "babylonjs/types";
  44356. import { Scene } from "babylonjs/scene";
  44357. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44359. import { Effect } from "babylonjs/Materials/effect";
  44360. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44361. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44362. /**
  44363. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44364. * These values define a cone of light starting from the position, emitting toward the direction.
  44365. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44366. * and the exponent defines the speed of the decay of the light with distance (reach).
  44367. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44368. */
  44369. export class SpotLight extends ShadowLight {
  44370. private _angle;
  44371. private _innerAngle;
  44372. private _cosHalfAngle;
  44373. private _lightAngleScale;
  44374. private _lightAngleOffset;
  44375. /**
  44376. * Gets the cone angle of the spot light in Radians.
  44377. */
  44378. /**
  44379. * Sets the cone angle of the spot light in Radians.
  44380. */
  44381. angle: number;
  44382. /**
  44383. * Only used in gltf falloff mode, this defines the angle where
  44384. * the directional falloff will start before cutting at angle which could be seen
  44385. * as outer angle.
  44386. */
  44387. /**
  44388. * Only used in gltf falloff mode, this defines the angle where
  44389. * the directional falloff will start before cutting at angle which could be seen
  44390. * as outer angle.
  44391. */
  44392. innerAngle: number;
  44393. private _shadowAngleScale;
  44394. /**
  44395. * Allows scaling the angle of the light for shadow generation only.
  44396. */
  44397. /**
  44398. * Allows scaling the angle of the light for shadow generation only.
  44399. */
  44400. shadowAngleScale: number;
  44401. /**
  44402. * The light decay speed with the distance from the emission spot.
  44403. */
  44404. exponent: number;
  44405. private _projectionTextureMatrix;
  44406. /**
  44407. * Allows reading the projecton texture
  44408. */
  44409. readonly projectionTextureMatrix: Matrix;
  44410. protected _projectionTextureLightNear: number;
  44411. /**
  44412. * Gets the near clip of the Spotlight for texture projection.
  44413. */
  44414. /**
  44415. * Sets the near clip of the Spotlight for texture projection.
  44416. */
  44417. projectionTextureLightNear: number;
  44418. protected _projectionTextureLightFar: number;
  44419. /**
  44420. * Gets the far clip of the Spotlight for texture projection.
  44421. */
  44422. /**
  44423. * Sets the far clip of the Spotlight for texture projection.
  44424. */
  44425. projectionTextureLightFar: number;
  44426. protected _projectionTextureUpDirection: Vector3;
  44427. /**
  44428. * Gets the Up vector of the Spotlight for texture projection.
  44429. */
  44430. /**
  44431. * Sets the Up vector of the Spotlight for texture projection.
  44432. */
  44433. projectionTextureUpDirection: Vector3;
  44434. private _projectionTexture;
  44435. /**
  44436. * Gets the projection texture of the light.
  44437. */
  44438. /**
  44439. * Sets the projection texture of the light.
  44440. */
  44441. projectionTexture: Nullable<BaseTexture>;
  44442. private _projectionTextureViewLightDirty;
  44443. private _projectionTextureProjectionLightDirty;
  44444. private _projectionTextureDirty;
  44445. private _projectionTextureViewTargetVector;
  44446. private _projectionTextureViewLightMatrix;
  44447. private _projectionTextureProjectionLightMatrix;
  44448. private _projectionTextureScalingMatrix;
  44449. /**
  44450. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44451. * It can cast shadows.
  44452. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44453. * @param name The light friendly name
  44454. * @param position The position of the spot light in the scene
  44455. * @param direction The direction of the light in the scene
  44456. * @param angle The cone angle of the light in Radians
  44457. * @param exponent The light decay speed with the distance from the emission spot
  44458. * @param scene The scene the lights belongs to
  44459. */
  44460. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44461. /**
  44462. * Returns the string "SpotLight".
  44463. * @returns the class name
  44464. */
  44465. getClassName(): string;
  44466. /**
  44467. * Returns the integer 2.
  44468. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44469. */
  44470. getTypeID(): number;
  44471. /**
  44472. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44473. */
  44474. protected _setDirection(value: Vector3): void;
  44475. /**
  44476. * Overrides the position setter to recompute the projection texture view light Matrix.
  44477. */
  44478. protected _setPosition(value: Vector3): void;
  44479. /**
  44480. * 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.
  44481. * Returns the SpotLight.
  44482. */
  44483. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44484. protected _computeProjectionTextureViewLightMatrix(): void;
  44485. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44486. /**
  44487. * Main function for light texture projection matrix computing.
  44488. */
  44489. protected _computeProjectionTextureMatrix(): void;
  44490. protected _buildUniformLayout(): void;
  44491. private _computeAngleValues;
  44492. /**
  44493. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44494. * @param effect The effect to update
  44495. * @param lightIndex The index of the light in the effect to update
  44496. * @returns The spot light
  44497. */
  44498. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44499. /**
  44500. * Disposes the light and the associated resources.
  44501. */
  44502. dispose(): void;
  44503. /**
  44504. * Prepares the list of defines specific to the light type.
  44505. * @param defines the list of defines
  44506. * @param lightIndex defines the index of the light for the effect
  44507. */
  44508. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44509. }
  44510. }
  44511. declare module "babylonjs/Gizmos/lightGizmo" {
  44512. import { Nullable } from "babylonjs/types";
  44513. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44514. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44515. import { Light } from "babylonjs/Lights/light";
  44516. /**
  44517. * Gizmo that enables viewing a light
  44518. */
  44519. export class LightGizmo extends Gizmo {
  44520. private _lightMesh;
  44521. private _material;
  44522. /**
  44523. * Creates a LightGizmo
  44524. * @param gizmoLayer The utility layer the gizmo will be added to
  44525. */
  44526. constructor(gizmoLayer?: UtilityLayerRenderer);
  44527. private _light;
  44528. /**
  44529. * The light that the gizmo is attached to
  44530. */
  44531. light: Nullable<Light>;
  44532. /**
  44533. * @hidden
  44534. * Updates the gizmo to match the attached mesh's position/rotation
  44535. */
  44536. protected _update(): void;
  44537. private static _Scale;
  44538. /**
  44539. * Creates the lines for a light mesh
  44540. */
  44541. private static _createLightLines;
  44542. private static _CreateHemisphericLightMesh;
  44543. private static _CreatePointLightMesh;
  44544. private static _CreateSpotLightMesh;
  44545. private static _CreateDirectionalLightMesh;
  44546. }
  44547. }
  44548. declare module "babylonjs/Gizmos/index" {
  44549. export * from "babylonjs/Gizmos/axisDragGizmo";
  44550. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44551. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44552. export * from "babylonjs/Gizmos/gizmo";
  44553. export * from "babylonjs/Gizmos/gizmoManager";
  44554. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44555. export * from "babylonjs/Gizmos/positionGizmo";
  44556. export * from "babylonjs/Gizmos/rotationGizmo";
  44557. export * from "babylonjs/Gizmos/scaleGizmo";
  44558. export * from "babylonjs/Gizmos/lightGizmo";
  44559. }
  44560. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44561. /** @hidden */
  44562. export var backgroundFragmentDeclaration: {
  44563. name: string;
  44564. shader: string;
  44565. };
  44566. }
  44567. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44568. /** @hidden */
  44569. export var backgroundUboDeclaration: {
  44570. name: string;
  44571. shader: string;
  44572. };
  44573. }
  44574. declare module "babylonjs/Shaders/background.fragment" {
  44575. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44576. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44577. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44578. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44579. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44580. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44581. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44582. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44583. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44584. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44585. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44586. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44587. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44588. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44589. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44590. /** @hidden */
  44591. export var backgroundPixelShader: {
  44592. name: string;
  44593. shader: string;
  44594. };
  44595. }
  44596. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44597. /** @hidden */
  44598. export var backgroundVertexDeclaration: {
  44599. name: string;
  44600. shader: string;
  44601. };
  44602. }
  44603. declare module "babylonjs/Shaders/background.vertex" {
  44604. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44605. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44606. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44607. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44608. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44609. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44610. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44611. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44612. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44613. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44614. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44615. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44616. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44617. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44618. /** @hidden */
  44619. export var backgroundVertexShader: {
  44620. name: string;
  44621. shader: string;
  44622. };
  44623. }
  44624. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44625. import { Nullable, int, float } from "babylonjs/types";
  44626. import { Scene } from "babylonjs/scene";
  44627. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44628. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44630. import { Mesh } from "babylonjs/Meshes/mesh";
  44631. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44632. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44633. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44635. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44636. import "babylonjs/Shaders/background.fragment";
  44637. import "babylonjs/Shaders/background.vertex";
  44638. /**
  44639. * Background material used to create an efficient environement around your scene.
  44640. */
  44641. export class BackgroundMaterial extends PushMaterial {
  44642. /**
  44643. * Standard reflectance value at parallel view angle.
  44644. */
  44645. static StandardReflectance0: number;
  44646. /**
  44647. * Standard reflectance value at grazing angle.
  44648. */
  44649. static StandardReflectance90: number;
  44650. protected _primaryColor: Color3;
  44651. /**
  44652. * Key light Color (multiply against the environement texture)
  44653. */
  44654. primaryColor: Color3;
  44655. protected __perceptualColor: Nullable<Color3>;
  44656. /**
  44657. * Experimental Internal Use Only.
  44658. *
  44659. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44660. * This acts as a helper to set the primary color to a more "human friendly" value.
  44661. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44662. * output color as close as possible from the chosen value.
  44663. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44664. * part of lighting setup.)
  44665. */
  44666. _perceptualColor: Nullable<Color3>;
  44667. protected _primaryColorShadowLevel: float;
  44668. /**
  44669. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44670. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44671. */
  44672. primaryColorShadowLevel: float;
  44673. protected _primaryColorHighlightLevel: float;
  44674. /**
  44675. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44676. * The primary color is used at the level chosen to define what the white area would look.
  44677. */
  44678. primaryColorHighlightLevel: float;
  44679. protected _reflectionTexture: Nullable<BaseTexture>;
  44680. /**
  44681. * Reflection Texture used in the material.
  44682. * Should be author in a specific way for the best result (refer to the documentation).
  44683. */
  44684. reflectionTexture: Nullable<BaseTexture>;
  44685. protected _reflectionBlur: float;
  44686. /**
  44687. * Reflection Texture level of blur.
  44688. *
  44689. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44690. * texture twice.
  44691. */
  44692. reflectionBlur: float;
  44693. protected _diffuseTexture: Nullable<BaseTexture>;
  44694. /**
  44695. * Diffuse Texture used in the material.
  44696. * Should be author in a specific way for the best result (refer to the documentation).
  44697. */
  44698. diffuseTexture: Nullable<BaseTexture>;
  44699. protected _shadowLights: Nullable<IShadowLight[]>;
  44700. /**
  44701. * Specify the list of lights casting shadow on the material.
  44702. * All scene shadow lights will be included if null.
  44703. */
  44704. shadowLights: Nullable<IShadowLight[]>;
  44705. protected _shadowLevel: float;
  44706. /**
  44707. * Helps adjusting the shadow to a softer level if required.
  44708. * 0 means black shadows and 1 means no shadows.
  44709. */
  44710. shadowLevel: float;
  44711. protected _sceneCenter: Vector3;
  44712. /**
  44713. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44714. * It is usually zero but might be interesting to modify according to your setup.
  44715. */
  44716. sceneCenter: Vector3;
  44717. protected _opacityFresnel: boolean;
  44718. /**
  44719. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44720. * This helps ensuring a nice transition when the camera goes under the ground.
  44721. */
  44722. opacityFresnel: boolean;
  44723. protected _reflectionFresnel: boolean;
  44724. /**
  44725. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44726. * This helps adding a mirror texture on the ground.
  44727. */
  44728. reflectionFresnel: boolean;
  44729. protected _reflectionFalloffDistance: number;
  44730. /**
  44731. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44732. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44733. */
  44734. reflectionFalloffDistance: number;
  44735. protected _reflectionAmount: number;
  44736. /**
  44737. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44738. */
  44739. reflectionAmount: number;
  44740. protected _reflectionReflectance0: number;
  44741. /**
  44742. * This specifies the weight of the reflection at grazing angle.
  44743. */
  44744. reflectionReflectance0: number;
  44745. protected _reflectionReflectance90: number;
  44746. /**
  44747. * This specifies the weight of the reflection at a perpendicular point of view.
  44748. */
  44749. reflectionReflectance90: number;
  44750. /**
  44751. * Sets the reflection reflectance fresnel values according to the default standard
  44752. * empirically know to work well :-)
  44753. */
  44754. reflectionStandardFresnelWeight: number;
  44755. protected _useRGBColor: boolean;
  44756. /**
  44757. * Helps to directly use the maps channels instead of their level.
  44758. */
  44759. useRGBColor: boolean;
  44760. protected _enableNoise: boolean;
  44761. /**
  44762. * This helps reducing the banding effect that could occur on the background.
  44763. */
  44764. enableNoise: boolean;
  44765. /**
  44766. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44767. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44768. * Recommended to be keep at 1.0 except for special cases.
  44769. */
  44770. fovMultiplier: number;
  44771. private _fovMultiplier;
  44772. /**
  44773. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44774. */
  44775. useEquirectangularFOV: boolean;
  44776. private _maxSimultaneousLights;
  44777. /**
  44778. * Number of Simultaneous lights allowed on the material.
  44779. */
  44780. maxSimultaneousLights: int;
  44781. /**
  44782. * Default configuration related to image processing available in the Background Material.
  44783. */
  44784. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44785. /**
  44786. * Keep track of the image processing observer to allow dispose and replace.
  44787. */
  44788. private _imageProcessingObserver;
  44789. /**
  44790. * Attaches a new image processing configuration to the PBR Material.
  44791. * @param configuration (if null the scene configuration will be use)
  44792. */
  44793. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44794. /**
  44795. * Gets the image processing configuration used either in this material.
  44796. */
  44797. /**
  44798. * Sets the Default image processing configuration used either in the this material.
  44799. *
  44800. * If sets to null, the scene one is in use.
  44801. */
  44802. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44803. /**
  44804. * Gets wether the color curves effect is enabled.
  44805. */
  44806. /**
  44807. * Sets wether the color curves effect is enabled.
  44808. */
  44809. cameraColorCurvesEnabled: boolean;
  44810. /**
  44811. * Gets wether the color grading effect is enabled.
  44812. */
  44813. /**
  44814. * Gets wether the color grading effect is enabled.
  44815. */
  44816. cameraColorGradingEnabled: boolean;
  44817. /**
  44818. * Gets wether tonemapping is enabled or not.
  44819. */
  44820. /**
  44821. * Sets wether tonemapping is enabled or not
  44822. */
  44823. cameraToneMappingEnabled: boolean;
  44824. /**
  44825. * The camera exposure used on this material.
  44826. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44827. * This corresponds to a photographic exposure.
  44828. */
  44829. /**
  44830. * The camera exposure used on this material.
  44831. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44832. * This corresponds to a photographic exposure.
  44833. */
  44834. cameraExposure: float;
  44835. /**
  44836. * Gets The camera contrast used on this material.
  44837. */
  44838. /**
  44839. * Sets The camera contrast used on this material.
  44840. */
  44841. cameraContrast: float;
  44842. /**
  44843. * Gets the Color Grading 2D Lookup Texture.
  44844. */
  44845. /**
  44846. * Sets the Color Grading 2D Lookup Texture.
  44847. */
  44848. cameraColorGradingTexture: Nullable<BaseTexture>;
  44849. /**
  44850. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44851. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44852. * 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;
  44853. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44854. */
  44855. /**
  44856. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44857. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44858. * 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;
  44859. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44860. */
  44861. cameraColorCurves: Nullable<ColorCurves>;
  44862. /**
  44863. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44864. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44865. */
  44866. switchToBGR: boolean;
  44867. private _renderTargets;
  44868. private _reflectionControls;
  44869. private _white;
  44870. private _primaryShadowColor;
  44871. private _primaryHighlightColor;
  44872. /**
  44873. * Instantiates a Background Material in the given scene
  44874. * @param name The friendly name of the material
  44875. * @param scene The scene to add the material to
  44876. */
  44877. constructor(name: string, scene: Scene);
  44878. /**
  44879. * Gets a boolean indicating that current material needs to register RTT
  44880. */
  44881. readonly hasRenderTargetTextures: boolean;
  44882. /**
  44883. * The entire material has been created in order to prevent overdraw.
  44884. * @returns false
  44885. */
  44886. needAlphaTesting(): boolean;
  44887. /**
  44888. * The entire material has been created in order to prevent overdraw.
  44889. * @returns true if blending is enable
  44890. */
  44891. needAlphaBlending(): boolean;
  44892. /**
  44893. * Checks wether the material is ready to be rendered for a given mesh.
  44894. * @param mesh The mesh to render
  44895. * @param subMesh The submesh to check against
  44896. * @param useInstances Specify wether or not the material is used with instances
  44897. * @returns true if all the dependencies are ready (Textures, Effects...)
  44898. */
  44899. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44900. /**
  44901. * Compute the primary color according to the chosen perceptual color.
  44902. */
  44903. private _computePrimaryColorFromPerceptualColor;
  44904. /**
  44905. * Compute the highlights and shadow colors according to their chosen levels.
  44906. */
  44907. private _computePrimaryColors;
  44908. /**
  44909. * Build the uniform buffer used in the material.
  44910. */
  44911. buildUniformLayout(): void;
  44912. /**
  44913. * Unbind the material.
  44914. */
  44915. unbind(): void;
  44916. /**
  44917. * Bind only the world matrix to the material.
  44918. * @param world The world matrix to bind.
  44919. */
  44920. bindOnlyWorldMatrix(world: Matrix): void;
  44921. /**
  44922. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44923. * @param world The world matrix to bind.
  44924. * @param subMesh The submesh to bind for.
  44925. */
  44926. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44927. /**
  44928. * Dispose the material.
  44929. * @param forceDisposeEffect Force disposal of the associated effect.
  44930. * @param forceDisposeTextures Force disposal of the associated textures.
  44931. */
  44932. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44933. /**
  44934. * Clones the material.
  44935. * @param name The cloned name.
  44936. * @returns The cloned material.
  44937. */
  44938. clone(name: string): BackgroundMaterial;
  44939. /**
  44940. * Serializes the current material to its JSON representation.
  44941. * @returns The JSON representation.
  44942. */
  44943. serialize(): any;
  44944. /**
  44945. * Gets the class name of the material
  44946. * @returns "BackgroundMaterial"
  44947. */
  44948. getClassName(): string;
  44949. /**
  44950. * Parse a JSON input to create back a background material.
  44951. * @param source The JSON data to parse
  44952. * @param scene The scene to create the parsed material in
  44953. * @param rootUrl The root url of the assets the material depends upon
  44954. * @returns the instantiated BackgroundMaterial.
  44955. */
  44956. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44957. }
  44958. }
  44959. declare module "babylonjs/Helpers/environmentHelper" {
  44960. import { Observable } from "babylonjs/Misc/observable";
  44961. import { Nullable } from "babylonjs/types";
  44962. import { Scene } from "babylonjs/scene";
  44963. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44965. import { Mesh } from "babylonjs/Meshes/mesh";
  44966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44967. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  44968. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  44969. import "babylonjs/Meshes/Builders/planeBuilder";
  44970. import "babylonjs/Meshes/Builders/boxBuilder";
  44971. /**
  44972. * Represents the different options available during the creation of
  44973. * a Environment helper.
  44974. *
  44975. * This can control the default ground, skybox and image processing setup of your scene.
  44976. */
  44977. export interface IEnvironmentHelperOptions {
  44978. /**
  44979. * Specifies wether or not to create a ground.
  44980. * True by default.
  44981. */
  44982. createGround: boolean;
  44983. /**
  44984. * Specifies the ground size.
  44985. * 15 by default.
  44986. */
  44987. groundSize: number;
  44988. /**
  44989. * The texture used on the ground for the main color.
  44990. * Comes from the BabylonJS CDN by default.
  44991. *
  44992. * Remarks: Can be either a texture or a url.
  44993. */
  44994. groundTexture: string | BaseTexture;
  44995. /**
  44996. * The color mixed in the ground texture by default.
  44997. * BabylonJS clearColor by default.
  44998. */
  44999. groundColor: Color3;
  45000. /**
  45001. * Specifies the ground opacity.
  45002. * 1 by default.
  45003. */
  45004. groundOpacity: number;
  45005. /**
  45006. * Enables the ground to receive shadows.
  45007. * True by default.
  45008. */
  45009. enableGroundShadow: boolean;
  45010. /**
  45011. * Helps preventing the shadow to be fully black on the ground.
  45012. * 0.5 by default.
  45013. */
  45014. groundShadowLevel: number;
  45015. /**
  45016. * Creates a mirror texture attach to the ground.
  45017. * false by default.
  45018. */
  45019. enableGroundMirror: boolean;
  45020. /**
  45021. * Specifies the ground mirror size ratio.
  45022. * 0.3 by default as the default kernel is 64.
  45023. */
  45024. groundMirrorSizeRatio: number;
  45025. /**
  45026. * Specifies the ground mirror blur kernel size.
  45027. * 64 by default.
  45028. */
  45029. groundMirrorBlurKernel: number;
  45030. /**
  45031. * Specifies the ground mirror visibility amount.
  45032. * 1 by default
  45033. */
  45034. groundMirrorAmount: number;
  45035. /**
  45036. * Specifies the ground mirror reflectance weight.
  45037. * This uses the standard weight of the background material to setup the fresnel effect
  45038. * of the mirror.
  45039. * 1 by default.
  45040. */
  45041. groundMirrorFresnelWeight: number;
  45042. /**
  45043. * Specifies the ground mirror Falloff distance.
  45044. * This can helps reducing the size of the reflection.
  45045. * 0 by Default.
  45046. */
  45047. groundMirrorFallOffDistance: number;
  45048. /**
  45049. * Specifies the ground mirror texture type.
  45050. * Unsigned Int by Default.
  45051. */
  45052. groundMirrorTextureType: number;
  45053. /**
  45054. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45055. * the shown objects.
  45056. */
  45057. groundYBias: number;
  45058. /**
  45059. * Specifies wether or not to create a skybox.
  45060. * True by default.
  45061. */
  45062. createSkybox: boolean;
  45063. /**
  45064. * Specifies the skybox size.
  45065. * 20 by default.
  45066. */
  45067. skyboxSize: number;
  45068. /**
  45069. * The texture used on the skybox for the main color.
  45070. * Comes from the BabylonJS CDN by default.
  45071. *
  45072. * Remarks: Can be either a texture or a url.
  45073. */
  45074. skyboxTexture: string | BaseTexture;
  45075. /**
  45076. * The color mixed in the skybox texture by default.
  45077. * BabylonJS clearColor by default.
  45078. */
  45079. skyboxColor: Color3;
  45080. /**
  45081. * The background rotation around the Y axis of the scene.
  45082. * This helps aligning the key lights of your scene with the background.
  45083. * 0 by default.
  45084. */
  45085. backgroundYRotation: number;
  45086. /**
  45087. * Compute automatically the size of the elements to best fit with the scene.
  45088. */
  45089. sizeAuto: boolean;
  45090. /**
  45091. * Default position of the rootMesh if autoSize is not true.
  45092. */
  45093. rootPosition: Vector3;
  45094. /**
  45095. * Sets up the image processing in the scene.
  45096. * true by default.
  45097. */
  45098. setupImageProcessing: boolean;
  45099. /**
  45100. * The texture used as your environment texture in the scene.
  45101. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45102. *
  45103. * Remarks: Can be either a texture or a url.
  45104. */
  45105. environmentTexture: string | BaseTexture;
  45106. /**
  45107. * The value of the exposure to apply to the scene.
  45108. * 0.6 by default if setupImageProcessing is true.
  45109. */
  45110. cameraExposure: number;
  45111. /**
  45112. * The value of the contrast to apply to the scene.
  45113. * 1.6 by default if setupImageProcessing is true.
  45114. */
  45115. cameraContrast: number;
  45116. /**
  45117. * Specifies wether or not tonemapping should be enabled in the scene.
  45118. * true by default if setupImageProcessing is true.
  45119. */
  45120. toneMappingEnabled: boolean;
  45121. }
  45122. /**
  45123. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45124. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45125. * It also helps with the default setup of your imageProcessing configuration.
  45126. */
  45127. export class EnvironmentHelper {
  45128. /**
  45129. * Default ground texture URL.
  45130. */
  45131. private static _groundTextureCDNUrl;
  45132. /**
  45133. * Default skybox texture URL.
  45134. */
  45135. private static _skyboxTextureCDNUrl;
  45136. /**
  45137. * Default environment texture URL.
  45138. */
  45139. private static _environmentTextureCDNUrl;
  45140. /**
  45141. * Creates the default options for the helper.
  45142. */
  45143. private static _getDefaultOptions;
  45144. private _rootMesh;
  45145. /**
  45146. * Gets the root mesh created by the helper.
  45147. */
  45148. readonly rootMesh: Mesh;
  45149. private _skybox;
  45150. /**
  45151. * Gets the skybox created by the helper.
  45152. */
  45153. readonly skybox: Nullable<Mesh>;
  45154. private _skyboxTexture;
  45155. /**
  45156. * Gets the skybox texture created by the helper.
  45157. */
  45158. readonly skyboxTexture: Nullable<BaseTexture>;
  45159. private _skyboxMaterial;
  45160. /**
  45161. * Gets the skybox material created by the helper.
  45162. */
  45163. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45164. private _ground;
  45165. /**
  45166. * Gets the ground mesh created by the helper.
  45167. */
  45168. readonly ground: Nullable<Mesh>;
  45169. private _groundTexture;
  45170. /**
  45171. * Gets the ground texture created by the helper.
  45172. */
  45173. readonly groundTexture: Nullable<BaseTexture>;
  45174. private _groundMirror;
  45175. /**
  45176. * Gets the ground mirror created by the helper.
  45177. */
  45178. readonly groundMirror: Nullable<MirrorTexture>;
  45179. /**
  45180. * Gets the ground mirror render list to helps pushing the meshes
  45181. * you wish in the ground reflection.
  45182. */
  45183. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45184. private _groundMaterial;
  45185. /**
  45186. * Gets the ground material created by the helper.
  45187. */
  45188. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45189. /**
  45190. * Stores the creation options.
  45191. */
  45192. private readonly _scene;
  45193. private _options;
  45194. /**
  45195. * This observable will be notified with any error during the creation of the environment,
  45196. * mainly texture creation errors.
  45197. */
  45198. onErrorObservable: Observable<{
  45199. message?: string;
  45200. exception?: any;
  45201. }>;
  45202. /**
  45203. * constructor
  45204. * @param options Defines the options we want to customize the helper
  45205. * @param scene The scene to add the material to
  45206. */
  45207. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45208. /**
  45209. * Updates the background according to the new options
  45210. * @param options
  45211. */
  45212. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45213. /**
  45214. * Sets the primary color of all the available elements.
  45215. * @param color the main color to affect to the ground and the background
  45216. */
  45217. setMainColor(color: Color3): void;
  45218. /**
  45219. * Setup the image processing according to the specified options.
  45220. */
  45221. private _setupImageProcessing;
  45222. /**
  45223. * Setup the environment texture according to the specified options.
  45224. */
  45225. private _setupEnvironmentTexture;
  45226. /**
  45227. * Setup the background according to the specified options.
  45228. */
  45229. private _setupBackground;
  45230. /**
  45231. * Get the scene sizes according to the setup.
  45232. */
  45233. private _getSceneSize;
  45234. /**
  45235. * Setup the ground according to the specified options.
  45236. */
  45237. private _setupGround;
  45238. /**
  45239. * Setup the ground material according to the specified options.
  45240. */
  45241. private _setupGroundMaterial;
  45242. /**
  45243. * Setup the ground diffuse texture according to the specified options.
  45244. */
  45245. private _setupGroundDiffuseTexture;
  45246. /**
  45247. * Setup the ground mirror texture according to the specified options.
  45248. */
  45249. private _setupGroundMirrorTexture;
  45250. /**
  45251. * Setup the ground to receive the mirror texture.
  45252. */
  45253. private _setupMirrorInGroundMaterial;
  45254. /**
  45255. * Setup the skybox according to the specified options.
  45256. */
  45257. private _setupSkybox;
  45258. /**
  45259. * Setup the skybox material according to the specified options.
  45260. */
  45261. private _setupSkyboxMaterial;
  45262. /**
  45263. * Setup the skybox reflection texture according to the specified options.
  45264. */
  45265. private _setupSkyboxReflectionTexture;
  45266. private _errorHandler;
  45267. /**
  45268. * Dispose all the elements created by the Helper.
  45269. */
  45270. dispose(): void;
  45271. }
  45272. }
  45273. declare module "babylonjs/Helpers/photoDome" {
  45274. import { Observable } from "babylonjs/Misc/observable";
  45275. import { Nullable } from "babylonjs/types";
  45276. import { Scene } from "babylonjs/scene";
  45277. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45278. import { Mesh } from "babylonjs/Meshes/mesh";
  45279. import { Texture } from "babylonjs/Materials/Textures/texture";
  45280. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45281. import "babylonjs/Meshes/Builders/sphereBuilder";
  45282. /**
  45283. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45284. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45285. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45286. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45287. */
  45288. export class PhotoDome extends TransformNode {
  45289. private _useDirectMapping;
  45290. /**
  45291. * The texture being displayed on the sphere
  45292. */
  45293. protected _photoTexture: Texture;
  45294. /**
  45295. * Gets or sets the texture being displayed on the sphere
  45296. */
  45297. photoTexture: Texture;
  45298. /**
  45299. * Observable raised when an error occured while loading the 360 image
  45300. */
  45301. onLoadErrorObservable: Observable<string>;
  45302. /**
  45303. * The skybox material
  45304. */
  45305. protected _material: BackgroundMaterial;
  45306. /**
  45307. * The surface used for the skybox
  45308. */
  45309. protected _mesh: Mesh;
  45310. /**
  45311. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45312. * Also see the options.resolution property.
  45313. */
  45314. fovMultiplier: number;
  45315. /**
  45316. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45317. * @param name Element's name, child elements will append suffixes for their own names.
  45318. * @param urlsOfPhoto defines the url of the photo to display
  45319. * @param options defines an object containing optional or exposed sub element properties
  45320. * @param onError defines a callback called when an error occured while loading the texture
  45321. */
  45322. constructor(name: string, urlOfPhoto: string, options: {
  45323. resolution?: number;
  45324. size?: number;
  45325. useDirectMapping?: boolean;
  45326. faceForward?: boolean;
  45327. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45328. /**
  45329. * Releases resources associated with this node.
  45330. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45331. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45332. */
  45333. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45334. }
  45335. }
  45336. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45337. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45338. /** @hidden */
  45339. export var rgbdDecodePixelShader: {
  45340. name: string;
  45341. shader: string;
  45342. };
  45343. }
  45344. declare module "babylonjs/Misc/brdfTextureTools" {
  45345. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45346. import { Scene } from "babylonjs/scene";
  45347. import "babylonjs/Shaders/rgbdDecode.fragment";
  45348. /**
  45349. * Class used to host texture specific utilities
  45350. */
  45351. export class BRDFTextureTools {
  45352. /**
  45353. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45354. * @param texture the texture to expand.
  45355. */
  45356. private static _ExpandDefaultBRDFTexture;
  45357. /**
  45358. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45359. * @param scene defines the hosting scene
  45360. * @returns the environment BRDF texture
  45361. */
  45362. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45363. private static _environmentBRDFBase64Texture;
  45364. }
  45365. }
  45366. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45367. import { Nullable } from "babylonjs/types";
  45368. import { IAnimatable } from "babylonjs/Misc/tools";
  45369. import { Color3 } from "babylonjs/Maths/math";
  45370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45371. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45372. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45373. import { Engine } from "babylonjs/Engines/engine";
  45374. import { Scene } from "babylonjs/scene";
  45375. /**
  45376. * @hidden
  45377. */
  45378. export interface IMaterialClearCoatDefines {
  45379. CLEARCOAT: boolean;
  45380. CLEARCOAT_DEFAULTIOR: boolean;
  45381. CLEARCOAT_TEXTURE: boolean;
  45382. CLEARCOAT_TEXTUREDIRECTUV: number;
  45383. CLEARCOAT_BUMP: boolean;
  45384. CLEARCOAT_BUMPDIRECTUV: number;
  45385. CLEARCOAT_TINT: boolean;
  45386. CLEARCOAT_TINT_TEXTURE: boolean;
  45387. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45388. /** @hidden */
  45389. _areTexturesDirty: boolean;
  45390. }
  45391. /**
  45392. * Define the code related to the clear coat parameters of the pbr material.
  45393. */
  45394. export class PBRClearCoatConfiguration {
  45395. /**
  45396. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45397. * The default fits with a polyurethane material.
  45398. */
  45399. private static readonly _DefaultIndiceOfRefraction;
  45400. private _isEnabled;
  45401. /**
  45402. * Defines if the clear coat is enabled in the material.
  45403. */
  45404. isEnabled: boolean;
  45405. /**
  45406. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45407. */
  45408. intensity: number;
  45409. /**
  45410. * Defines the clear coat layer roughness.
  45411. */
  45412. roughness: number;
  45413. private _indiceOfRefraction;
  45414. /**
  45415. * Defines the indice of refraction of the clear coat.
  45416. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45417. * The default fits with a polyurethane material.
  45418. * Changing the default value is more performance intensive.
  45419. */
  45420. indiceOfRefraction: number;
  45421. private _texture;
  45422. /**
  45423. * Stores the clear coat values in a texture.
  45424. */
  45425. texture: Nullable<BaseTexture>;
  45426. private _bumpTexture;
  45427. /**
  45428. * Define the clear coat specific bump texture.
  45429. */
  45430. bumpTexture: Nullable<BaseTexture>;
  45431. private _isTintEnabled;
  45432. /**
  45433. * Defines if the clear coat tint is enabled in the material.
  45434. */
  45435. isTintEnabled: boolean;
  45436. /**
  45437. * Defines the clear coat tint of the material.
  45438. * This is only use if tint is enabled
  45439. */
  45440. tintColor: Color3;
  45441. /**
  45442. * Defines the distance at which the tint color should be found in the
  45443. * clear coat media.
  45444. * This is only use if tint is enabled
  45445. */
  45446. tintColorAtDistance: number;
  45447. /**
  45448. * Defines the clear coat layer thickness.
  45449. * This is only use if tint is enabled
  45450. */
  45451. tintThickness: number;
  45452. private _tintTexture;
  45453. /**
  45454. * Stores the clear tint values in a texture.
  45455. * rgb is tint
  45456. * a is a thickness factor
  45457. */
  45458. tintTexture: Nullable<BaseTexture>;
  45459. /** @hidden */
  45460. private _internalMarkAllSubMeshesAsTexturesDirty;
  45461. /** @hidden */
  45462. _markAllSubMeshesAsTexturesDirty(): void;
  45463. /**
  45464. * Instantiate a new istance of clear coat configuration.
  45465. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45466. */
  45467. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45468. /**
  45469. * Gets wehter the submesh is ready to be used or not.
  45470. * @param defines the list of "defines" to update.
  45471. * @param scene defines the scene the material belongs to.
  45472. * @param engine defines the engine the material belongs to.
  45473. * @param disableBumpMap defines wether the material disables bump or not.
  45474. * @returns - boolean indicating that the submesh is ready or not.
  45475. */
  45476. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45477. /**
  45478. * Checks to see if a texture is used in the material.
  45479. * @param defines the list of "defines" to update.
  45480. * @param scene defines the scene to the material belongs to.
  45481. */
  45482. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45483. /**
  45484. * Binds the material data.
  45485. * @param uniformBuffer defines the Uniform buffer to fill in.
  45486. * @param scene defines the scene the material belongs to.
  45487. * @param engine defines the engine the material belongs to.
  45488. * @param disableBumpMap defines wether the material disables bump or not.
  45489. * @param isFrozen defines wether the material is frozen or not.
  45490. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45491. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45492. */
  45493. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45494. /**
  45495. * Checks to see if a texture is used in the material.
  45496. * @param texture - Base texture to use.
  45497. * @returns - Boolean specifying if a texture is used in the material.
  45498. */
  45499. hasTexture(texture: BaseTexture): boolean;
  45500. /**
  45501. * Returns an array of the actively used textures.
  45502. * @param activeTextures Array of BaseTextures
  45503. */
  45504. getActiveTextures(activeTextures: BaseTexture[]): void;
  45505. /**
  45506. * Returns the animatable textures.
  45507. * @param animatables Array of animatable textures.
  45508. */
  45509. getAnimatables(animatables: IAnimatable[]): void;
  45510. /**
  45511. * Disposes the resources of the material.
  45512. * @param forceDisposeTextures - Forces the disposal of all textures.
  45513. */
  45514. dispose(forceDisposeTextures?: boolean): void;
  45515. /**
  45516. * Get the current class name of the texture useful for serialization or dynamic coding.
  45517. * @returns "PBRClearCoatConfiguration"
  45518. */
  45519. getClassName(): string;
  45520. /**
  45521. * Add fallbacks to the effect fallbacks list.
  45522. * @param defines defines the Base texture to use.
  45523. * @param fallbacks defines the current fallback list.
  45524. * @param currentRank defines the current fallback rank.
  45525. * @returns the new fallback rank.
  45526. */
  45527. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45528. /**
  45529. * Add the required uniforms to the current list.
  45530. * @param uniforms defines the current uniform list.
  45531. */
  45532. static AddUniforms(uniforms: string[]): void;
  45533. /**
  45534. * Add the required samplers to the current list.
  45535. * @param samplers defines the current sampler list.
  45536. */
  45537. static AddSamplers(samplers: string[]): void;
  45538. /**
  45539. * Add the required uniforms to the current buffer.
  45540. * @param uniformBuffer defines the current uniform buffer.
  45541. */
  45542. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45543. /**
  45544. * Makes a duplicate of the current configuration into another one.
  45545. * @param clearCoatConfiguration define the config where to copy the info
  45546. */
  45547. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45548. /**
  45549. * Serializes this clear coat configuration.
  45550. * @returns - An object with the serialized config.
  45551. */
  45552. serialize(): any;
  45553. /**
  45554. * Parses a Clear Coat Configuration from a serialized object.
  45555. * @param source - Serialized object.
  45556. */
  45557. parse(source: any): void;
  45558. }
  45559. }
  45560. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45561. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45562. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45564. import { Vector2 } from "babylonjs/Maths/math";
  45565. import { Scene } from "babylonjs/scene";
  45566. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45567. import { IAnimatable } from "babylonjs/Misc/tools";
  45568. import { Nullable } from "babylonjs/types";
  45569. /**
  45570. * @hidden
  45571. */
  45572. export interface IMaterialAnisotropicDefines {
  45573. ANISOTROPIC: boolean;
  45574. ANISOTROPIC_TEXTURE: boolean;
  45575. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45576. MAINUV1: boolean;
  45577. _areTexturesDirty: boolean;
  45578. _needUVs: boolean;
  45579. }
  45580. /**
  45581. * Define the code related to the anisotropic parameters of the pbr material.
  45582. */
  45583. export class PBRAnisotropicConfiguration {
  45584. private _isEnabled;
  45585. /**
  45586. * Defines if the anisotropy is enabled in the material.
  45587. */
  45588. isEnabled: boolean;
  45589. /**
  45590. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45591. */
  45592. intensity: number;
  45593. /**
  45594. * Defines if the effect is along the tangents, bitangents or in between.
  45595. * By default, the effect is "strectching" the highlights along the tangents.
  45596. */
  45597. direction: Vector2;
  45598. private _texture;
  45599. /**
  45600. * Stores the anisotropy values in a texture.
  45601. * rg is direction (like normal from -1 to 1)
  45602. * b is a intensity
  45603. */
  45604. texture: Nullable<BaseTexture>;
  45605. /** @hidden */
  45606. private _internalMarkAllSubMeshesAsTexturesDirty;
  45607. /** @hidden */
  45608. _markAllSubMeshesAsTexturesDirty(): void;
  45609. /**
  45610. * Instantiate a new istance of anisotropy configuration.
  45611. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45612. */
  45613. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45614. /**
  45615. * Specifies that the submesh is ready to be used.
  45616. * @param defines the list of "defines" to update.
  45617. * @param scene defines the scene the material belongs to.
  45618. * @returns - boolean indicating that the submesh is ready or not.
  45619. */
  45620. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45621. /**
  45622. * Checks to see if a texture is used in the material.
  45623. * @param defines the list of "defines" to update.
  45624. * @param mesh the mesh we are preparing the defines for.
  45625. * @param scene defines the scene the material belongs to.
  45626. */
  45627. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45628. /**
  45629. * Binds the material data.
  45630. * @param uniformBuffer defines the Uniform buffer to fill in.
  45631. * @param scene defines the scene the material belongs to.
  45632. * @param isFrozen defines wether the material is frozen or not.
  45633. */
  45634. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45635. /**
  45636. * Checks to see if a texture is used in the material.
  45637. * @param texture - Base texture to use.
  45638. * @returns - Boolean specifying if a texture is used in the material.
  45639. */
  45640. hasTexture(texture: BaseTexture): boolean;
  45641. /**
  45642. * Returns an array of the actively used textures.
  45643. * @param activeTextures Array of BaseTextures
  45644. */
  45645. getActiveTextures(activeTextures: BaseTexture[]): void;
  45646. /**
  45647. * Returns the animatable textures.
  45648. * @param animatables Array of animatable textures.
  45649. */
  45650. getAnimatables(animatables: IAnimatable[]): void;
  45651. /**
  45652. * Disposes the resources of the material.
  45653. * @param forceDisposeTextures - Forces the disposal of all textures.
  45654. */
  45655. dispose(forceDisposeTextures?: boolean): void;
  45656. /**
  45657. * Get the current class name of the texture useful for serialization or dynamic coding.
  45658. * @returns "PBRAnisotropicConfiguration"
  45659. */
  45660. getClassName(): string;
  45661. /**
  45662. * Add fallbacks to the effect fallbacks list.
  45663. * @param defines defines the Base texture to use.
  45664. * @param fallbacks defines the current fallback list.
  45665. * @param currentRank defines the current fallback rank.
  45666. * @returns the new fallback rank.
  45667. */
  45668. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45669. /**
  45670. * Add the required uniforms to the current list.
  45671. * @param uniforms defines the current uniform list.
  45672. */
  45673. static AddUniforms(uniforms: string[]): void;
  45674. /**
  45675. * Add the required uniforms to the current buffer.
  45676. * @param uniformBuffer defines the current uniform buffer.
  45677. */
  45678. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45679. /**
  45680. * Add the required samplers to the current list.
  45681. * @param samplers defines the current sampler list.
  45682. */
  45683. static AddSamplers(samplers: string[]): void;
  45684. /**
  45685. * Makes a duplicate of the current configuration into another one.
  45686. * @param anisotropicConfiguration define the config where to copy the info
  45687. */
  45688. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45689. /**
  45690. * Serializes this anisotropy configuration.
  45691. * @returns - An object with the serialized config.
  45692. */
  45693. serialize(): any;
  45694. /**
  45695. * Parses a anisotropy Configuration from a serialized object.
  45696. * @param source - Serialized object.
  45697. */
  45698. parse(source: any): void;
  45699. }
  45700. }
  45701. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45702. /**
  45703. * @hidden
  45704. */
  45705. export interface IMaterialBRDFDefines {
  45706. BRDF_V_HEIGHT_CORRELATED: boolean;
  45707. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45708. /** @hidden */
  45709. _areMiscDirty: boolean;
  45710. }
  45711. /**
  45712. * Define the code related to the BRDF parameters of the pbr material.
  45713. */
  45714. export class PBRBRDFConfiguration {
  45715. /**
  45716. * Default value used for the energy conservation.
  45717. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45718. */
  45719. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45720. /**
  45721. * Default value used for the Smith Visibility Height Correlated mode.
  45722. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45723. */
  45724. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45725. private _useEnergyConservation;
  45726. /**
  45727. * Defines if the material uses energy conservation.
  45728. */
  45729. useEnergyConservation: boolean;
  45730. private _useSmithVisibilityHeightCorrelated;
  45731. /**
  45732. * LEGACY Mode set to false
  45733. * Defines if the material uses height smith correlated visibility term.
  45734. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45735. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45736. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45737. * Not relying on height correlated will also disable energy conservation.
  45738. */
  45739. useSmithVisibilityHeightCorrelated: boolean;
  45740. /** @hidden */
  45741. private _internalMarkAllSubMeshesAsMiscDirty;
  45742. /** @hidden */
  45743. _markAllSubMeshesAsMiscDirty(): void;
  45744. /**
  45745. * Instantiate a new istance of clear coat configuration.
  45746. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45747. */
  45748. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45749. /**
  45750. * Checks to see if a texture is used in the material.
  45751. * @param defines the list of "defines" to update.
  45752. */
  45753. prepareDefines(defines: IMaterialBRDFDefines): void;
  45754. /**
  45755. * Get the current class name of the texture useful for serialization or dynamic coding.
  45756. * @returns "PBRClearCoatConfiguration"
  45757. */
  45758. getClassName(): string;
  45759. /**
  45760. * Makes a duplicate of the current configuration into another one.
  45761. * @param brdfConfiguration define the config where to copy the info
  45762. */
  45763. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45764. /**
  45765. * Serializes this BRDF configuration.
  45766. * @returns - An object with the serialized config.
  45767. */
  45768. serialize(): any;
  45769. /**
  45770. * Parses a BRDF Configuration from a serialized object.
  45771. * @param source - Serialized object.
  45772. */
  45773. parse(source: any): void;
  45774. }
  45775. }
  45776. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45777. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45778. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45779. import { Color3 } from "babylonjs/Maths/math";
  45780. import { Scene } from "babylonjs/scene";
  45781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45782. import { IAnimatable } from "babylonjs/Misc/tools";
  45783. import { Nullable } from "babylonjs/types";
  45784. /**
  45785. * @hidden
  45786. */
  45787. export interface IMaterialSheenDefines {
  45788. SHEEN: boolean;
  45789. SHEEN_TEXTURE: boolean;
  45790. SHEEN_TEXTUREDIRECTUV: number;
  45791. SHEEN_LINKWITHALBEDO: boolean;
  45792. /** @hidden */
  45793. _areTexturesDirty: boolean;
  45794. }
  45795. /**
  45796. * Define the code related to the Sheen parameters of the pbr material.
  45797. */
  45798. export class PBRSheenConfiguration {
  45799. private _isEnabled;
  45800. /**
  45801. * Defines if the material uses sheen.
  45802. */
  45803. isEnabled: boolean;
  45804. private _linkSheenWithAlbedo;
  45805. /**
  45806. * Defines if the sheen is linked to the sheen color.
  45807. */
  45808. linkSheenWithAlbedo: boolean;
  45809. /**
  45810. * Defines the sheen intensity.
  45811. */
  45812. intensity: number;
  45813. /**
  45814. * Defines the sheen color.
  45815. */
  45816. color: Color3;
  45817. private _texture;
  45818. /**
  45819. * Stores the sheen tint values in a texture.
  45820. * rgb is tint
  45821. * a is a intensity
  45822. */
  45823. texture: Nullable<BaseTexture>;
  45824. /** @hidden */
  45825. private _internalMarkAllSubMeshesAsTexturesDirty;
  45826. /** @hidden */
  45827. _markAllSubMeshesAsTexturesDirty(): void;
  45828. /**
  45829. * Instantiate a new istance of clear coat configuration.
  45830. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45831. */
  45832. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45833. /**
  45834. * Specifies that the submesh is ready to be used.
  45835. * @param defines the list of "defines" to update.
  45836. * @param scene defines the scene the material belongs to.
  45837. * @returns - boolean indicating that the submesh is ready or not.
  45838. */
  45839. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45840. /**
  45841. * Checks to see if a texture is used in the material.
  45842. * @param defines the list of "defines" to update.
  45843. * @param scene defines the scene the material belongs to.
  45844. */
  45845. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45846. /**
  45847. * Binds the material data.
  45848. * @param uniformBuffer defines the Uniform buffer to fill in.
  45849. * @param scene defines the scene the material belongs to.
  45850. * @param isFrozen defines wether the material is frozen or not.
  45851. */
  45852. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45853. /**
  45854. * Checks to see if a texture is used in the material.
  45855. * @param texture - Base texture to use.
  45856. * @returns - Boolean specifying if a texture is used in the material.
  45857. */
  45858. hasTexture(texture: BaseTexture): boolean;
  45859. /**
  45860. * Returns an array of the actively used textures.
  45861. * @param activeTextures Array of BaseTextures
  45862. */
  45863. getActiveTextures(activeTextures: BaseTexture[]): void;
  45864. /**
  45865. * Returns the animatable textures.
  45866. * @param animatables Array of animatable textures.
  45867. */
  45868. getAnimatables(animatables: IAnimatable[]): void;
  45869. /**
  45870. * Disposes the resources of the material.
  45871. * @param forceDisposeTextures - Forces the disposal of all textures.
  45872. */
  45873. dispose(forceDisposeTextures?: boolean): void;
  45874. /**
  45875. * Get the current class name of the texture useful for serialization or dynamic coding.
  45876. * @returns "PBRSheenConfiguration"
  45877. */
  45878. getClassName(): string;
  45879. /**
  45880. * Add fallbacks to the effect fallbacks list.
  45881. * @param defines defines the Base texture to use.
  45882. * @param fallbacks defines the current fallback list.
  45883. * @param currentRank defines the current fallback rank.
  45884. * @returns the new fallback rank.
  45885. */
  45886. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45887. /**
  45888. * Add the required uniforms to the current list.
  45889. * @param uniforms defines the current uniform list.
  45890. */
  45891. static AddUniforms(uniforms: string[]): void;
  45892. /**
  45893. * Add the required uniforms to the current buffer.
  45894. * @param uniformBuffer defines the current uniform buffer.
  45895. */
  45896. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45897. /**
  45898. * Add the required samplers to the current list.
  45899. * @param samplers defines the current sampler list.
  45900. */
  45901. static AddSamplers(samplers: string[]): void;
  45902. /**
  45903. * Makes a duplicate of the current configuration into another one.
  45904. * @param sheenConfiguration define the config where to copy the info
  45905. */
  45906. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45907. /**
  45908. * Serializes this BRDF configuration.
  45909. * @returns - An object with the serialized config.
  45910. */
  45911. serialize(): any;
  45912. /**
  45913. * Parses a Sheen Configuration from a serialized object.
  45914. * @param source - Serialized object.
  45915. */
  45916. parse(source: any): void;
  45917. }
  45918. }
  45919. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45920. import { Nullable } from "babylonjs/types";
  45921. import { IAnimatable } from "babylonjs/Misc/tools";
  45922. import { Color3 } from "babylonjs/Maths/math";
  45923. import { SmartArray } from "babylonjs/Misc/smartArray";
  45924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45925. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45926. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45927. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45928. import { Engine } from "babylonjs/Engines/engine";
  45929. import { Scene } from "babylonjs/scene";
  45930. /**
  45931. * @hidden
  45932. */
  45933. export interface IMaterialSubSurfaceDefines {
  45934. SUBSURFACE: boolean;
  45935. SS_REFRACTION: boolean;
  45936. SS_TRANSLUCENCY: boolean;
  45937. SS_SCATERRING: boolean;
  45938. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45939. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45940. SS_REFRACTIONMAP_3D: boolean;
  45941. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45942. SS_LODINREFRACTIONALPHA: boolean;
  45943. SS_GAMMAREFRACTION: boolean;
  45944. SS_RGBDREFRACTION: boolean;
  45945. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45946. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45947. /** @hidden */
  45948. _areTexturesDirty: boolean;
  45949. }
  45950. /**
  45951. * Define the code related to the sub surface parameters of the pbr material.
  45952. */
  45953. export class PBRSubSurfaceConfiguration {
  45954. private _isRefractionEnabled;
  45955. /**
  45956. * Defines if the refraction is enabled in the material.
  45957. */
  45958. isRefractionEnabled: boolean;
  45959. private _isTranslucencyEnabled;
  45960. /**
  45961. * Defines if the translucency is enabled in the material.
  45962. */
  45963. isTranslucencyEnabled: boolean;
  45964. private _isScatteringEnabled;
  45965. /**
  45966. * Defines the refraction intensity of the material.
  45967. * The refraction when enabled replaces the Diffuse part of the material.
  45968. * The intensity helps transitionning between diffuse and refraction.
  45969. */
  45970. refractionIntensity: number;
  45971. /**
  45972. * Defines the translucency intensity of the material.
  45973. * When translucency has been enabled, this defines how much of the "translucency"
  45974. * is addded to the diffuse part of the material.
  45975. */
  45976. translucencyIntensity: number;
  45977. /**
  45978. * Defines the scattering intensity of the material.
  45979. * When scattering has been enabled, this defines how much of the "scattered light"
  45980. * is addded to the diffuse part of the material.
  45981. */
  45982. scatteringIntensity: number;
  45983. private _thicknessTexture;
  45984. /**
  45985. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45986. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45987. * 0 would mean minimumThickness
  45988. * 1 would mean maximumThickness
  45989. * The other channels might be use as a mask to vary the different effects intensity.
  45990. */
  45991. thicknessTexture: Nullable<BaseTexture>;
  45992. private _refractionTexture;
  45993. /**
  45994. * Defines the texture to use for refraction.
  45995. */
  45996. refractionTexture: Nullable<BaseTexture>;
  45997. private _indexOfRefraction;
  45998. /**
  45999. * Defines the indice of refraction used in the material.
  46000. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46001. */
  46002. indexOfRefraction: number;
  46003. private _invertRefractionY;
  46004. /**
  46005. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46006. */
  46007. invertRefractionY: boolean;
  46008. private _linkRefractionWithTransparency;
  46009. /**
  46010. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46011. * Materials half opaque for instance using refraction could benefit from this control.
  46012. */
  46013. linkRefractionWithTransparency: boolean;
  46014. /**
  46015. * Defines the minimum thickness stored in the thickness map.
  46016. * If no thickness map is defined, this value will be used to simulate thickness.
  46017. */
  46018. minimumThickness: number;
  46019. /**
  46020. * Defines the maximum thickness stored in the thickness map.
  46021. */
  46022. maximumThickness: number;
  46023. /**
  46024. * Defines the volume tint of the material.
  46025. * This is used for both translucency and scattering.
  46026. */
  46027. tintColor: Color3;
  46028. /**
  46029. * Defines the distance at which the tint color should be found in the media.
  46030. * This is used for refraction only.
  46031. */
  46032. tintColorAtDistance: number;
  46033. /**
  46034. * Defines how far each channel transmit through the media.
  46035. * It is defined as a color to simplify it selection.
  46036. */
  46037. diffusionDistance: Color3;
  46038. private _useMaskFromThicknessTexture;
  46039. /**
  46040. * Stores the intensity of the different subsurface effects in the thickness texture.
  46041. * * the green channel is the translucency intensity.
  46042. * * the blue channel is the scattering intensity.
  46043. * * the alpha channel is the refraction intensity.
  46044. */
  46045. useMaskFromThicknessTexture: boolean;
  46046. /** @hidden */
  46047. private _internalMarkAllSubMeshesAsTexturesDirty;
  46048. /** @hidden */
  46049. _markAllSubMeshesAsTexturesDirty(): void;
  46050. /**
  46051. * Instantiate a new istance of sub surface configuration.
  46052. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46053. */
  46054. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46055. /**
  46056. * Gets wehter the submesh is ready to be used or not.
  46057. * @param defines the list of "defines" to update.
  46058. * @param scene defines the scene the material belongs to.
  46059. * @returns - boolean indicating that the submesh is ready or not.
  46060. */
  46061. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46062. /**
  46063. * Checks to see if a texture is used in the material.
  46064. * @param defines the list of "defines" to update.
  46065. * @param scene defines the scene to the material belongs to.
  46066. */
  46067. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46068. /**
  46069. * Binds the material data.
  46070. * @param uniformBuffer defines the Uniform buffer to fill in.
  46071. * @param scene defines the scene the material belongs to.
  46072. * @param engine defines the engine the material belongs to.
  46073. * @param isFrozen defines wether the material is frozen or not.
  46074. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46075. */
  46076. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46077. /**
  46078. * Unbinds the material from the mesh.
  46079. * @param activeEffect defines the effect that should be unbound from.
  46080. * @returns true if unbound, otherwise false
  46081. */
  46082. unbind(activeEffect: Effect): boolean;
  46083. /**
  46084. * Returns the texture used for refraction or null if none is used.
  46085. * @param scene defines the scene the material belongs to.
  46086. * @returns - Refraction texture if present. If no refraction texture and refraction
  46087. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46088. */
  46089. private _getRefractionTexture;
  46090. /**
  46091. * Returns true if alpha blending should be disabled.
  46092. */
  46093. readonly disableAlphaBlending: boolean;
  46094. /**
  46095. * Fills the list of render target textures.
  46096. * @param renderTargets the list of render targets to update
  46097. */
  46098. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46099. /**
  46100. * Checks to see if a texture is used in the material.
  46101. * @param texture - Base texture to use.
  46102. * @returns - Boolean specifying if a texture is used in the material.
  46103. */
  46104. hasTexture(texture: BaseTexture): boolean;
  46105. /**
  46106. * Gets a boolean indicating that current material needs to register RTT
  46107. * @returns true if this uses a render target otherwise false.
  46108. */
  46109. hasRenderTargetTextures(): boolean;
  46110. /**
  46111. * Returns an array of the actively used textures.
  46112. * @param activeTextures Array of BaseTextures
  46113. */
  46114. getActiveTextures(activeTextures: BaseTexture[]): void;
  46115. /**
  46116. * Returns the animatable textures.
  46117. * @param animatables Array of animatable textures.
  46118. */
  46119. getAnimatables(animatables: IAnimatable[]): void;
  46120. /**
  46121. * Disposes the resources of the material.
  46122. * @param forceDisposeTextures - Forces the disposal of all textures.
  46123. */
  46124. dispose(forceDisposeTextures?: boolean): void;
  46125. /**
  46126. * Get the current class name of the texture useful for serialization or dynamic coding.
  46127. * @returns "PBRSubSurfaceConfiguration"
  46128. */
  46129. getClassName(): string;
  46130. /**
  46131. * Add fallbacks to the effect fallbacks list.
  46132. * @param defines defines the Base texture to use.
  46133. * @param fallbacks defines the current fallback list.
  46134. * @param currentRank defines the current fallback rank.
  46135. * @returns the new fallback rank.
  46136. */
  46137. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46138. /**
  46139. * Add the required uniforms to the current list.
  46140. * @param uniforms defines the current uniform list.
  46141. */
  46142. static AddUniforms(uniforms: string[]): void;
  46143. /**
  46144. * Add the required samplers to the current list.
  46145. * @param samplers defines the current sampler list.
  46146. */
  46147. static AddSamplers(samplers: string[]): void;
  46148. /**
  46149. * Add the required uniforms to the current buffer.
  46150. * @param uniformBuffer defines the current uniform buffer.
  46151. */
  46152. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46153. /**
  46154. * Makes a duplicate of the current configuration into another one.
  46155. * @param configuration define the config where to copy the info
  46156. */
  46157. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46158. /**
  46159. * Serializes this Sub Surface configuration.
  46160. * @returns - An object with the serialized config.
  46161. */
  46162. serialize(): any;
  46163. /**
  46164. * Parses a Sub Surface Configuration from a serialized object.
  46165. * @param source - Serialized object.
  46166. */
  46167. parse(source: any): void;
  46168. }
  46169. }
  46170. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46171. /** @hidden */
  46172. export var pbrFragmentDeclaration: {
  46173. name: string;
  46174. shader: string;
  46175. };
  46176. }
  46177. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46178. /** @hidden */
  46179. export var pbrUboDeclaration: {
  46180. name: string;
  46181. shader: string;
  46182. };
  46183. }
  46184. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46185. /** @hidden */
  46186. export var pbrFragmentExtraDeclaration: {
  46187. name: string;
  46188. shader: string;
  46189. };
  46190. }
  46191. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46192. /** @hidden */
  46193. export var pbrFragmentSamplersDeclaration: {
  46194. name: string;
  46195. shader: string;
  46196. };
  46197. }
  46198. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46199. /** @hidden */
  46200. export var pbrHelperFunctions: {
  46201. name: string;
  46202. shader: string;
  46203. };
  46204. }
  46205. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46206. /** @hidden */
  46207. export var harmonicsFunctions: {
  46208. name: string;
  46209. shader: string;
  46210. };
  46211. }
  46212. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46213. /** @hidden */
  46214. export var pbrDirectLightingSetupFunctions: {
  46215. name: string;
  46216. shader: string;
  46217. };
  46218. }
  46219. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46220. /** @hidden */
  46221. export var pbrDirectLightingFalloffFunctions: {
  46222. name: string;
  46223. shader: string;
  46224. };
  46225. }
  46226. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46227. /** @hidden */
  46228. export var pbrBRDFFunctions: {
  46229. name: string;
  46230. shader: string;
  46231. };
  46232. }
  46233. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46234. /** @hidden */
  46235. export var pbrDirectLightingFunctions: {
  46236. name: string;
  46237. shader: string;
  46238. };
  46239. }
  46240. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46241. /** @hidden */
  46242. export var pbrIBLFunctions: {
  46243. name: string;
  46244. shader: string;
  46245. };
  46246. }
  46247. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46248. /** @hidden */
  46249. export var pbrDebug: {
  46250. name: string;
  46251. shader: string;
  46252. };
  46253. }
  46254. declare module "babylonjs/Shaders/pbr.fragment" {
  46255. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46256. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46257. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46258. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46259. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46260. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46261. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46262. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46263. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46264. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46265. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46266. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46267. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46268. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46269. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46270. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46271. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46272. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46273. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46274. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46275. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46276. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46277. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46278. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46279. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46280. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46281. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46282. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46283. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46284. /** @hidden */
  46285. export var pbrPixelShader: {
  46286. name: string;
  46287. shader: string;
  46288. };
  46289. }
  46290. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46291. /** @hidden */
  46292. export var pbrVertexDeclaration: {
  46293. name: string;
  46294. shader: string;
  46295. };
  46296. }
  46297. declare module "babylonjs/Shaders/pbr.vertex" {
  46298. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46299. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46300. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46301. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46302. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46303. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46304. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46305. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46306. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46307. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46308. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46309. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46310. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46311. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46312. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46313. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46314. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46315. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46316. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46317. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46318. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46319. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46320. /** @hidden */
  46321. export var pbrVertexShader: {
  46322. name: string;
  46323. shader: string;
  46324. };
  46325. }
  46326. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46327. import { IAnimatable } from "babylonjs/Misc/tools";
  46328. import { Nullable } from "babylonjs/types";
  46329. import { Scene } from "babylonjs/scene";
  46330. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46331. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46332. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46333. import { Mesh } from "babylonjs/Meshes/mesh";
  46334. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46335. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46336. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46337. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46338. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46339. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46340. import { Material } from "babylonjs/Materials/material";
  46341. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46342. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46343. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46344. import "babylonjs/Shaders/pbr.fragment";
  46345. import "babylonjs/Shaders/pbr.vertex";
  46346. /**
  46347. * Manages the defines for the PBR Material.
  46348. * @hidden
  46349. */
  46350. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46351. PBR: boolean;
  46352. MAINUV1: boolean;
  46353. MAINUV2: boolean;
  46354. UV1: boolean;
  46355. UV2: boolean;
  46356. ALBEDO: boolean;
  46357. ALBEDODIRECTUV: number;
  46358. VERTEXCOLOR: boolean;
  46359. AMBIENT: boolean;
  46360. AMBIENTDIRECTUV: number;
  46361. AMBIENTINGRAYSCALE: boolean;
  46362. OPACITY: boolean;
  46363. VERTEXALPHA: boolean;
  46364. OPACITYDIRECTUV: number;
  46365. OPACITYRGB: boolean;
  46366. ALPHATEST: boolean;
  46367. DEPTHPREPASS: boolean;
  46368. ALPHABLEND: boolean;
  46369. ALPHAFROMALBEDO: boolean;
  46370. ALPHATESTVALUE: string;
  46371. SPECULAROVERALPHA: boolean;
  46372. RADIANCEOVERALPHA: boolean;
  46373. ALPHAFRESNEL: boolean;
  46374. LINEARALPHAFRESNEL: boolean;
  46375. PREMULTIPLYALPHA: boolean;
  46376. EMISSIVE: boolean;
  46377. EMISSIVEDIRECTUV: number;
  46378. REFLECTIVITY: boolean;
  46379. REFLECTIVITYDIRECTUV: number;
  46380. SPECULARTERM: boolean;
  46381. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46382. MICROSURFACEAUTOMATIC: boolean;
  46383. LODBASEDMICROSFURACE: boolean;
  46384. MICROSURFACEMAP: boolean;
  46385. MICROSURFACEMAPDIRECTUV: number;
  46386. METALLICWORKFLOW: boolean;
  46387. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46388. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46389. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46390. AOSTOREINMETALMAPRED: boolean;
  46391. ENVIRONMENTBRDF: boolean;
  46392. ENVIRONMENTBRDF_RGBD: boolean;
  46393. NORMAL: boolean;
  46394. TANGENT: boolean;
  46395. BUMP: boolean;
  46396. BUMPDIRECTUV: number;
  46397. OBJECTSPACE_NORMALMAP: boolean;
  46398. PARALLAX: boolean;
  46399. PARALLAXOCCLUSION: boolean;
  46400. NORMALXYSCALE: boolean;
  46401. LIGHTMAP: boolean;
  46402. LIGHTMAPDIRECTUV: number;
  46403. USELIGHTMAPASSHADOWMAP: boolean;
  46404. GAMMALIGHTMAP: boolean;
  46405. REFLECTION: boolean;
  46406. REFLECTIONMAP_3D: boolean;
  46407. REFLECTIONMAP_SPHERICAL: boolean;
  46408. REFLECTIONMAP_PLANAR: boolean;
  46409. REFLECTIONMAP_CUBIC: boolean;
  46410. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46411. REFLECTIONMAP_PROJECTION: boolean;
  46412. REFLECTIONMAP_SKYBOX: boolean;
  46413. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46414. REFLECTIONMAP_EXPLICIT: boolean;
  46415. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46416. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46417. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46418. INVERTCUBICMAP: boolean;
  46419. USESPHERICALFROMREFLECTIONMAP: boolean;
  46420. USESPHERICALINVERTEX: boolean;
  46421. REFLECTIONMAP_OPPOSITEZ: boolean;
  46422. LODINREFLECTIONALPHA: boolean;
  46423. GAMMAREFLECTION: boolean;
  46424. RGBDREFLECTION: boolean;
  46425. RADIANCEOCCLUSION: boolean;
  46426. HORIZONOCCLUSION: boolean;
  46427. INSTANCES: boolean;
  46428. NUM_BONE_INFLUENCERS: number;
  46429. BonesPerMesh: number;
  46430. BONETEXTURE: boolean;
  46431. NONUNIFORMSCALING: boolean;
  46432. MORPHTARGETS: boolean;
  46433. MORPHTARGETS_NORMAL: boolean;
  46434. MORPHTARGETS_TANGENT: boolean;
  46435. NUM_MORPH_INFLUENCERS: number;
  46436. IMAGEPROCESSING: boolean;
  46437. VIGNETTE: boolean;
  46438. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46439. VIGNETTEBLENDMODEOPAQUE: boolean;
  46440. TONEMAPPING: boolean;
  46441. TONEMAPPING_ACES: boolean;
  46442. CONTRAST: boolean;
  46443. COLORCURVES: boolean;
  46444. COLORGRADING: boolean;
  46445. COLORGRADING3D: boolean;
  46446. SAMPLER3DGREENDEPTH: boolean;
  46447. SAMPLER3DBGRMAP: boolean;
  46448. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46449. EXPOSURE: boolean;
  46450. MULTIVIEW: boolean;
  46451. USEPHYSICALLIGHTFALLOFF: boolean;
  46452. USEGLTFLIGHTFALLOFF: boolean;
  46453. TWOSIDEDLIGHTING: boolean;
  46454. SHADOWFLOAT: boolean;
  46455. CLIPPLANE: boolean;
  46456. CLIPPLANE2: boolean;
  46457. CLIPPLANE3: boolean;
  46458. CLIPPLANE4: boolean;
  46459. POINTSIZE: boolean;
  46460. FOG: boolean;
  46461. LOGARITHMICDEPTH: boolean;
  46462. FORCENORMALFORWARD: boolean;
  46463. SPECULARAA: boolean;
  46464. CLEARCOAT: boolean;
  46465. CLEARCOAT_DEFAULTIOR: boolean;
  46466. CLEARCOAT_TEXTURE: boolean;
  46467. CLEARCOAT_TEXTUREDIRECTUV: number;
  46468. CLEARCOAT_BUMP: boolean;
  46469. CLEARCOAT_BUMPDIRECTUV: number;
  46470. CLEARCOAT_TINT: boolean;
  46471. CLEARCOAT_TINT_TEXTURE: boolean;
  46472. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46473. ANISOTROPIC: boolean;
  46474. ANISOTROPIC_TEXTURE: boolean;
  46475. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46476. BRDF_V_HEIGHT_CORRELATED: boolean;
  46477. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46478. SHEEN: boolean;
  46479. SHEEN_TEXTURE: boolean;
  46480. SHEEN_TEXTUREDIRECTUV: number;
  46481. SHEEN_LINKWITHALBEDO: boolean;
  46482. SUBSURFACE: boolean;
  46483. SS_REFRACTION: boolean;
  46484. SS_TRANSLUCENCY: boolean;
  46485. SS_SCATERRING: boolean;
  46486. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46487. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46488. SS_REFRACTIONMAP_3D: boolean;
  46489. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46490. SS_LODINREFRACTIONALPHA: boolean;
  46491. SS_GAMMAREFRACTION: boolean;
  46492. SS_RGBDREFRACTION: boolean;
  46493. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46494. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46495. UNLIT: boolean;
  46496. DEBUGMODE: number;
  46497. /**
  46498. * Initializes the PBR Material defines.
  46499. */
  46500. constructor();
  46501. /**
  46502. * Resets the PBR Material defines.
  46503. */
  46504. reset(): void;
  46505. }
  46506. /**
  46507. * The Physically based material base class of BJS.
  46508. *
  46509. * This offers the main features of a standard PBR material.
  46510. * For more information, please refer to the documentation :
  46511. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46512. */
  46513. export abstract class PBRBaseMaterial extends PushMaterial {
  46514. /**
  46515. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46516. */
  46517. static readonly PBRMATERIAL_OPAQUE: number;
  46518. /**
  46519. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46520. */
  46521. static readonly PBRMATERIAL_ALPHATEST: number;
  46522. /**
  46523. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46524. */
  46525. static readonly PBRMATERIAL_ALPHABLEND: number;
  46526. /**
  46527. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46528. * They are also discarded below the alpha cutoff threshold to improve performances.
  46529. */
  46530. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46531. /**
  46532. * Defines the default value of how much AO map is occluding the analytical lights
  46533. * (point spot...).
  46534. */
  46535. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46536. /**
  46537. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46538. */
  46539. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46540. /**
  46541. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46542. * to enhance interoperability with other engines.
  46543. */
  46544. static readonly LIGHTFALLOFF_GLTF: number;
  46545. /**
  46546. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46547. * to enhance interoperability with other materials.
  46548. */
  46549. static readonly LIGHTFALLOFF_STANDARD: number;
  46550. /**
  46551. * Intensity of the direct lights e.g. the four lights available in your scene.
  46552. * This impacts both the direct diffuse and specular highlights.
  46553. */
  46554. protected _directIntensity: number;
  46555. /**
  46556. * Intensity of the emissive part of the material.
  46557. * This helps controlling the emissive effect without modifying the emissive color.
  46558. */
  46559. protected _emissiveIntensity: number;
  46560. /**
  46561. * Intensity of the environment e.g. how much the environment will light the object
  46562. * either through harmonics for rough material or through the refelction for shiny ones.
  46563. */
  46564. protected _environmentIntensity: number;
  46565. /**
  46566. * This is a special control allowing the reduction of the specular highlights coming from the
  46567. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46568. */
  46569. protected _specularIntensity: number;
  46570. /**
  46571. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46572. */
  46573. private _lightingInfos;
  46574. /**
  46575. * Debug Control allowing disabling the bump map on this material.
  46576. */
  46577. protected _disableBumpMap: boolean;
  46578. /**
  46579. * AKA Diffuse Texture in standard nomenclature.
  46580. */
  46581. protected _albedoTexture: Nullable<BaseTexture>;
  46582. /**
  46583. * AKA Occlusion Texture in other nomenclature.
  46584. */
  46585. protected _ambientTexture: Nullable<BaseTexture>;
  46586. /**
  46587. * AKA Occlusion Texture Intensity in other nomenclature.
  46588. */
  46589. protected _ambientTextureStrength: number;
  46590. /**
  46591. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46592. * 1 means it completely occludes it
  46593. * 0 mean it has no impact
  46594. */
  46595. protected _ambientTextureImpactOnAnalyticalLights: number;
  46596. /**
  46597. * Stores the alpha values in a texture.
  46598. */
  46599. protected _opacityTexture: Nullable<BaseTexture>;
  46600. /**
  46601. * Stores the reflection values in a texture.
  46602. */
  46603. protected _reflectionTexture: Nullable<BaseTexture>;
  46604. /**
  46605. * Stores the emissive values in a texture.
  46606. */
  46607. protected _emissiveTexture: Nullable<BaseTexture>;
  46608. /**
  46609. * AKA Specular texture in other nomenclature.
  46610. */
  46611. protected _reflectivityTexture: Nullable<BaseTexture>;
  46612. /**
  46613. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46614. */
  46615. protected _metallicTexture: Nullable<BaseTexture>;
  46616. /**
  46617. * Specifies the metallic scalar of the metallic/roughness workflow.
  46618. * Can also be used to scale the metalness values of the metallic texture.
  46619. */
  46620. protected _metallic: Nullable<number>;
  46621. /**
  46622. * Specifies the roughness scalar of the metallic/roughness workflow.
  46623. * Can also be used to scale the roughness values of the metallic texture.
  46624. */
  46625. protected _roughness: Nullable<number>;
  46626. /**
  46627. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46628. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46629. */
  46630. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46631. /**
  46632. * Stores surface normal data used to displace a mesh in a texture.
  46633. */
  46634. protected _bumpTexture: Nullable<BaseTexture>;
  46635. /**
  46636. * Stores the pre-calculated light information of a mesh in a texture.
  46637. */
  46638. protected _lightmapTexture: Nullable<BaseTexture>;
  46639. /**
  46640. * The color of a material in ambient lighting.
  46641. */
  46642. protected _ambientColor: Color3;
  46643. /**
  46644. * AKA Diffuse Color in other nomenclature.
  46645. */
  46646. protected _albedoColor: Color3;
  46647. /**
  46648. * AKA Specular Color in other nomenclature.
  46649. */
  46650. protected _reflectivityColor: Color3;
  46651. /**
  46652. * The color applied when light is reflected from a material.
  46653. */
  46654. protected _reflectionColor: Color3;
  46655. /**
  46656. * The color applied when light is emitted from a material.
  46657. */
  46658. protected _emissiveColor: Color3;
  46659. /**
  46660. * AKA Glossiness in other nomenclature.
  46661. */
  46662. protected _microSurface: number;
  46663. /**
  46664. * Specifies that the material will use the light map as a show map.
  46665. */
  46666. protected _useLightmapAsShadowmap: boolean;
  46667. /**
  46668. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46669. * makes the reflect vector face the model (under horizon).
  46670. */
  46671. protected _useHorizonOcclusion: boolean;
  46672. /**
  46673. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46674. * too much the area relying on ambient texture to define their ambient occlusion.
  46675. */
  46676. protected _useRadianceOcclusion: boolean;
  46677. /**
  46678. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46679. */
  46680. protected _useAlphaFromAlbedoTexture: boolean;
  46681. /**
  46682. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46683. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46684. */
  46685. protected _useSpecularOverAlpha: boolean;
  46686. /**
  46687. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46688. */
  46689. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46690. /**
  46691. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46692. */
  46693. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46694. /**
  46695. * Specifies if the metallic texture contains the roughness information in its green channel.
  46696. */
  46697. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46698. /**
  46699. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46700. */
  46701. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46702. /**
  46703. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46704. */
  46705. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46706. /**
  46707. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46708. */
  46709. protected _useAmbientInGrayScale: boolean;
  46710. /**
  46711. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46712. * The material will try to infer what glossiness each pixel should be.
  46713. */
  46714. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46715. /**
  46716. * Defines the falloff type used in this material.
  46717. * It by default is Physical.
  46718. */
  46719. protected _lightFalloff: number;
  46720. /**
  46721. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46722. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46723. */
  46724. protected _useRadianceOverAlpha: boolean;
  46725. /**
  46726. * Allows using an object space normal map (instead of tangent space).
  46727. */
  46728. protected _useObjectSpaceNormalMap: boolean;
  46729. /**
  46730. * Allows using the bump map in parallax mode.
  46731. */
  46732. protected _useParallax: boolean;
  46733. /**
  46734. * Allows using the bump map in parallax occlusion mode.
  46735. */
  46736. protected _useParallaxOcclusion: boolean;
  46737. /**
  46738. * Controls the scale bias of the parallax mode.
  46739. */
  46740. protected _parallaxScaleBias: number;
  46741. /**
  46742. * If sets to true, disables all the lights affecting the material.
  46743. */
  46744. protected _disableLighting: boolean;
  46745. /**
  46746. * Number of Simultaneous lights allowed on the material.
  46747. */
  46748. protected _maxSimultaneousLights: number;
  46749. /**
  46750. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46751. */
  46752. protected _invertNormalMapX: boolean;
  46753. /**
  46754. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46755. */
  46756. protected _invertNormalMapY: boolean;
  46757. /**
  46758. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46759. */
  46760. protected _twoSidedLighting: boolean;
  46761. /**
  46762. * Defines the alpha limits in alpha test mode.
  46763. */
  46764. protected _alphaCutOff: number;
  46765. /**
  46766. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46767. */
  46768. protected _forceAlphaTest: boolean;
  46769. /**
  46770. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46771. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46772. */
  46773. protected _useAlphaFresnel: boolean;
  46774. /**
  46775. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46776. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46777. */
  46778. protected _useLinearAlphaFresnel: boolean;
  46779. /**
  46780. * The transparency mode of the material.
  46781. */
  46782. protected _transparencyMode: Nullable<number>;
  46783. /**
  46784. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46785. * from cos thetav and roughness:
  46786. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46787. */
  46788. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46789. /**
  46790. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46791. */
  46792. protected _forceIrradianceInFragment: boolean;
  46793. /**
  46794. * Force normal to face away from face.
  46795. */
  46796. protected _forceNormalForward: boolean;
  46797. /**
  46798. * Enables specular anti aliasing in the PBR shader.
  46799. * It will both interacts on the Geometry for analytical and IBL lighting.
  46800. * It also prefilter the roughness map based on the bump values.
  46801. */
  46802. protected _enableSpecularAntiAliasing: boolean;
  46803. /**
  46804. * Default configuration related to image processing available in the PBR Material.
  46805. */
  46806. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46807. /**
  46808. * Keep track of the image processing observer to allow dispose and replace.
  46809. */
  46810. private _imageProcessingObserver;
  46811. /**
  46812. * Attaches a new image processing configuration to the PBR Material.
  46813. * @param configuration
  46814. */
  46815. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46816. /**
  46817. * Stores the available render targets.
  46818. */
  46819. private _renderTargets;
  46820. /**
  46821. * Sets the global ambient color for the material used in lighting calculations.
  46822. */
  46823. private _globalAmbientColor;
  46824. /**
  46825. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46826. */
  46827. private _useLogarithmicDepth;
  46828. /**
  46829. * If set to true, no lighting calculations will be applied.
  46830. */
  46831. private _unlit;
  46832. private _debugMode;
  46833. /**
  46834. * @hidden
  46835. * This is reserved for the inspector.
  46836. * Defines the material debug mode.
  46837. * It helps seeing only some components of the material while troubleshooting.
  46838. */
  46839. debugMode: number;
  46840. /**
  46841. * @hidden
  46842. * This is reserved for the inspector.
  46843. * Specify from where on screen the debug mode should start.
  46844. * The value goes from -1 (full screen) to 1 (not visible)
  46845. * It helps with side by side comparison against the final render
  46846. * This defaults to -1
  46847. */
  46848. private debugLimit;
  46849. /**
  46850. * @hidden
  46851. * This is reserved for the inspector.
  46852. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46853. * You can use the factor to better multiply the final value.
  46854. */
  46855. private debugFactor;
  46856. /**
  46857. * Defines the clear coat layer parameters for the material.
  46858. */
  46859. readonly clearCoat: PBRClearCoatConfiguration;
  46860. /**
  46861. * Defines the anisotropic parameters for the material.
  46862. */
  46863. readonly anisotropy: PBRAnisotropicConfiguration;
  46864. /**
  46865. * Defines the BRDF parameters for the material.
  46866. */
  46867. readonly brdf: PBRBRDFConfiguration;
  46868. /**
  46869. * Defines the Sheen parameters for the material.
  46870. */
  46871. readonly sheen: PBRSheenConfiguration;
  46872. /**
  46873. * Defines the SubSurface parameters for the material.
  46874. */
  46875. readonly subSurface: PBRSubSurfaceConfiguration;
  46876. /**
  46877. * Custom callback helping to override the default shader used in the material.
  46878. */
  46879. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46880. /**
  46881. * Instantiates a new PBRMaterial instance.
  46882. *
  46883. * @param name The material name
  46884. * @param scene The scene the material will be use in.
  46885. */
  46886. constructor(name: string, scene: Scene);
  46887. /**
  46888. * Gets a boolean indicating that current material needs to register RTT
  46889. */
  46890. readonly hasRenderTargetTextures: boolean;
  46891. /**
  46892. * Gets the name of the material class.
  46893. */
  46894. getClassName(): string;
  46895. /**
  46896. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46897. */
  46898. /**
  46899. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46900. */
  46901. useLogarithmicDepth: boolean;
  46902. /**
  46903. * Gets the current transparency mode.
  46904. */
  46905. /**
  46906. * Sets the transparency mode of the material.
  46907. *
  46908. * | Value | Type | Description |
  46909. * | ----- | ----------------------------------- | ----------- |
  46910. * | 0 | OPAQUE | |
  46911. * | 1 | ALPHATEST | |
  46912. * | 2 | ALPHABLEND | |
  46913. * | 3 | ALPHATESTANDBLEND | |
  46914. *
  46915. */
  46916. transparencyMode: Nullable<number>;
  46917. /**
  46918. * Returns true if alpha blending should be disabled.
  46919. */
  46920. private readonly _disableAlphaBlending;
  46921. /**
  46922. * Specifies whether or not this material should be rendered in alpha blend mode.
  46923. */
  46924. needAlphaBlending(): boolean;
  46925. /**
  46926. * Specifies if the mesh will require alpha blending.
  46927. * @param mesh - BJS mesh.
  46928. */
  46929. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46930. /**
  46931. * Specifies whether or not this material should be rendered in alpha test mode.
  46932. */
  46933. needAlphaTesting(): boolean;
  46934. /**
  46935. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46936. */
  46937. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46938. /**
  46939. * Gets the texture used for the alpha test.
  46940. */
  46941. getAlphaTestTexture(): Nullable<BaseTexture>;
  46942. /**
  46943. * Specifies that the submesh is ready to be used.
  46944. * @param mesh - BJS mesh.
  46945. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46946. * @param useInstances - Specifies that instances should be used.
  46947. * @returns - boolean indicating that the submesh is ready or not.
  46948. */
  46949. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46950. /**
  46951. * Specifies if the material uses metallic roughness workflow.
  46952. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46953. */
  46954. isMetallicWorkflow(): boolean;
  46955. private _prepareEffect;
  46956. private _prepareDefines;
  46957. /**
  46958. * Force shader compilation
  46959. */
  46960. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46961. clipPlane: boolean;
  46962. }>): void;
  46963. /**
  46964. * Initializes the uniform buffer layout for the shader.
  46965. */
  46966. buildUniformLayout(): void;
  46967. /**
  46968. * Unbinds the material from the mesh
  46969. */
  46970. unbind(): void;
  46971. /**
  46972. * Binds the submesh data.
  46973. * @param world - The world matrix.
  46974. * @param mesh - The BJS mesh.
  46975. * @param subMesh - A submesh of the BJS mesh.
  46976. */
  46977. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46978. /**
  46979. * Returns the animatable textures.
  46980. * @returns - Array of animatable textures.
  46981. */
  46982. getAnimatables(): IAnimatable[];
  46983. /**
  46984. * Returns the texture used for reflections.
  46985. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46986. */
  46987. private _getReflectionTexture;
  46988. /**
  46989. * Returns an array of the actively used textures.
  46990. * @returns - Array of BaseTextures
  46991. */
  46992. getActiveTextures(): BaseTexture[];
  46993. /**
  46994. * Checks to see if a texture is used in the material.
  46995. * @param texture - Base texture to use.
  46996. * @returns - Boolean specifying if a texture is used in the material.
  46997. */
  46998. hasTexture(texture: BaseTexture): boolean;
  46999. /**
  47000. * Disposes the resources of the material.
  47001. * @param forceDisposeEffect - Forces the disposal of effects.
  47002. * @param forceDisposeTextures - Forces the disposal of all textures.
  47003. */
  47004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47005. }
  47006. }
  47007. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47008. import { Nullable } from "babylonjs/types";
  47009. import { Scene } from "babylonjs/scene";
  47010. import { Color3 } from "babylonjs/Maths/math";
  47011. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47012. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47013. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47014. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47015. /**
  47016. * The Physically based material of BJS.
  47017. *
  47018. * This offers the main features of a standard PBR material.
  47019. * For more information, please refer to the documentation :
  47020. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47021. */
  47022. export class PBRMaterial extends PBRBaseMaterial {
  47023. /**
  47024. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47025. */
  47026. static readonly PBRMATERIAL_OPAQUE: number;
  47027. /**
  47028. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47029. */
  47030. static readonly PBRMATERIAL_ALPHATEST: number;
  47031. /**
  47032. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47033. */
  47034. static readonly PBRMATERIAL_ALPHABLEND: number;
  47035. /**
  47036. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47037. * They are also discarded below the alpha cutoff threshold to improve performances.
  47038. */
  47039. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47040. /**
  47041. * Defines the default value of how much AO map is occluding the analytical lights
  47042. * (point spot...).
  47043. */
  47044. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47045. /**
  47046. * Intensity of the direct lights e.g. the four lights available in your scene.
  47047. * This impacts both the direct diffuse and specular highlights.
  47048. */
  47049. directIntensity: number;
  47050. /**
  47051. * Intensity of the emissive part of the material.
  47052. * This helps controlling the emissive effect without modifying the emissive color.
  47053. */
  47054. emissiveIntensity: number;
  47055. /**
  47056. * Intensity of the environment e.g. how much the environment will light the object
  47057. * either through harmonics for rough material or through the refelction for shiny ones.
  47058. */
  47059. environmentIntensity: number;
  47060. /**
  47061. * This is a special control allowing the reduction of the specular highlights coming from the
  47062. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47063. */
  47064. specularIntensity: number;
  47065. /**
  47066. * Debug Control allowing disabling the bump map on this material.
  47067. */
  47068. disableBumpMap: boolean;
  47069. /**
  47070. * AKA Diffuse Texture in standard nomenclature.
  47071. */
  47072. albedoTexture: BaseTexture;
  47073. /**
  47074. * AKA Occlusion Texture in other nomenclature.
  47075. */
  47076. ambientTexture: BaseTexture;
  47077. /**
  47078. * AKA Occlusion Texture Intensity in other nomenclature.
  47079. */
  47080. ambientTextureStrength: number;
  47081. /**
  47082. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47083. * 1 means it completely occludes it
  47084. * 0 mean it has no impact
  47085. */
  47086. ambientTextureImpactOnAnalyticalLights: number;
  47087. /**
  47088. * Stores the alpha values in a texture.
  47089. */
  47090. opacityTexture: BaseTexture;
  47091. /**
  47092. * Stores the reflection values in a texture.
  47093. */
  47094. reflectionTexture: Nullable<BaseTexture>;
  47095. /**
  47096. * Stores the emissive values in a texture.
  47097. */
  47098. emissiveTexture: BaseTexture;
  47099. /**
  47100. * AKA Specular texture in other nomenclature.
  47101. */
  47102. reflectivityTexture: BaseTexture;
  47103. /**
  47104. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47105. */
  47106. metallicTexture: BaseTexture;
  47107. /**
  47108. * Specifies the metallic scalar of the metallic/roughness workflow.
  47109. * Can also be used to scale the metalness values of the metallic texture.
  47110. */
  47111. metallic: Nullable<number>;
  47112. /**
  47113. * Specifies the roughness scalar of the metallic/roughness workflow.
  47114. * Can also be used to scale the roughness values of the metallic texture.
  47115. */
  47116. roughness: Nullable<number>;
  47117. /**
  47118. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47119. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47120. */
  47121. microSurfaceTexture: BaseTexture;
  47122. /**
  47123. * Stores surface normal data used to displace a mesh in a texture.
  47124. */
  47125. bumpTexture: BaseTexture;
  47126. /**
  47127. * Stores the pre-calculated light information of a mesh in a texture.
  47128. */
  47129. lightmapTexture: BaseTexture;
  47130. /**
  47131. * Stores the refracted light information in a texture.
  47132. */
  47133. refractionTexture: Nullable<BaseTexture>;
  47134. /**
  47135. * The color of a material in ambient lighting.
  47136. */
  47137. ambientColor: Color3;
  47138. /**
  47139. * AKA Diffuse Color in other nomenclature.
  47140. */
  47141. albedoColor: Color3;
  47142. /**
  47143. * AKA Specular Color in other nomenclature.
  47144. */
  47145. reflectivityColor: Color3;
  47146. /**
  47147. * The color reflected from the material.
  47148. */
  47149. reflectionColor: Color3;
  47150. /**
  47151. * The color emitted from the material.
  47152. */
  47153. emissiveColor: Color3;
  47154. /**
  47155. * AKA Glossiness in other nomenclature.
  47156. */
  47157. microSurface: number;
  47158. /**
  47159. * source material index of refraction (IOR)' / 'destination material IOR.
  47160. */
  47161. indexOfRefraction: number;
  47162. /**
  47163. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47164. */
  47165. invertRefractionY: boolean;
  47166. /**
  47167. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47168. * Materials half opaque for instance using refraction could benefit from this control.
  47169. */
  47170. linkRefractionWithTransparency: boolean;
  47171. /**
  47172. * If true, the light map contains occlusion information instead of lighting info.
  47173. */
  47174. useLightmapAsShadowmap: boolean;
  47175. /**
  47176. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47177. */
  47178. useAlphaFromAlbedoTexture: boolean;
  47179. /**
  47180. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47181. */
  47182. forceAlphaTest: boolean;
  47183. /**
  47184. * Defines the alpha limits in alpha test mode.
  47185. */
  47186. alphaCutOff: number;
  47187. /**
  47188. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47189. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47190. */
  47191. useSpecularOverAlpha: boolean;
  47192. /**
  47193. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47194. */
  47195. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47196. /**
  47197. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47198. */
  47199. useRoughnessFromMetallicTextureAlpha: boolean;
  47200. /**
  47201. * Specifies if the metallic texture contains the roughness information in its green channel.
  47202. */
  47203. useRoughnessFromMetallicTextureGreen: boolean;
  47204. /**
  47205. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47206. */
  47207. useMetallnessFromMetallicTextureBlue: boolean;
  47208. /**
  47209. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47210. */
  47211. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47212. /**
  47213. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47214. */
  47215. useAmbientInGrayScale: boolean;
  47216. /**
  47217. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47218. * The material will try to infer what glossiness each pixel should be.
  47219. */
  47220. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47221. /**
  47222. * BJS is using an harcoded light falloff based on a manually sets up range.
  47223. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47224. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47225. */
  47226. /**
  47227. * BJS is using an harcoded light falloff based on a manually sets up range.
  47228. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47229. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47230. */
  47231. usePhysicalLightFalloff: boolean;
  47232. /**
  47233. * In order to support the falloff compatibility with gltf, a special mode has been added
  47234. * to reproduce the gltf light falloff.
  47235. */
  47236. /**
  47237. * In order to support the falloff compatibility with gltf, a special mode has been added
  47238. * to reproduce the gltf light falloff.
  47239. */
  47240. useGLTFLightFalloff: boolean;
  47241. /**
  47242. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47243. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47244. */
  47245. useRadianceOverAlpha: boolean;
  47246. /**
  47247. * Allows using an object space normal map (instead of tangent space).
  47248. */
  47249. useObjectSpaceNormalMap: boolean;
  47250. /**
  47251. * Allows using the bump map in parallax mode.
  47252. */
  47253. useParallax: boolean;
  47254. /**
  47255. * Allows using the bump map in parallax occlusion mode.
  47256. */
  47257. useParallaxOcclusion: boolean;
  47258. /**
  47259. * Controls the scale bias of the parallax mode.
  47260. */
  47261. parallaxScaleBias: number;
  47262. /**
  47263. * If sets to true, disables all the lights affecting the material.
  47264. */
  47265. disableLighting: boolean;
  47266. /**
  47267. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47268. */
  47269. forceIrradianceInFragment: boolean;
  47270. /**
  47271. * Number of Simultaneous lights allowed on the material.
  47272. */
  47273. maxSimultaneousLights: number;
  47274. /**
  47275. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47276. */
  47277. invertNormalMapX: boolean;
  47278. /**
  47279. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47280. */
  47281. invertNormalMapY: boolean;
  47282. /**
  47283. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47284. */
  47285. twoSidedLighting: boolean;
  47286. /**
  47287. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47288. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47289. */
  47290. useAlphaFresnel: boolean;
  47291. /**
  47292. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47293. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47294. */
  47295. useLinearAlphaFresnel: boolean;
  47296. /**
  47297. * Let user defines the brdf lookup texture used for IBL.
  47298. * A default 8bit version is embedded but you could point at :
  47299. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47300. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47301. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47302. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47303. */
  47304. environmentBRDFTexture: Nullable<BaseTexture>;
  47305. /**
  47306. * Force normal to face away from face.
  47307. */
  47308. forceNormalForward: boolean;
  47309. /**
  47310. * Enables specular anti aliasing in the PBR shader.
  47311. * It will both interacts on the Geometry for analytical and IBL lighting.
  47312. * It also prefilter the roughness map based on the bump values.
  47313. */
  47314. enableSpecularAntiAliasing: boolean;
  47315. /**
  47316. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47317. * makes the reflect vector face the model (under horizon).
  47318. */
  47319. useHorizonOcclusion: boolean;
  47320. /**
  47321. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47322. * too much the area relying on ambient texture to define their ambient occlusion.
  47323. */
  47324. useRadianceOcclusion: boolean;
  47325. /**
  47326. * If set to true, no lighting calculations will be applied.
  47327. */
  47328. unlit: boolean;
  47329. /**
  47330. * Gets the image processing configuration used either in this material.
  47331. */
  47332. /**
  47333. * Sets the Default image processing configuration used either in the this material.
  47334. *
  47335. * If sets to null, the scene one is in use.
  47336. */
  47337. imageProcessingConfiguration: ImageProcessingConfiguration;
  47338. /**
  47339. * Gets wether the color curves effect is enabled.
  47340. */
  47341. /**
  47342. * Sets wether the color curves effect is enabled.
  47343. */
  47344. cameraColorCurvesEnabled: boolean;
  47345. /**
  47346. * Gets wether the color grading effect is enabled.
  47347. */
  47348. /**
  47349. * Gets wether the color grading effect is enabled.
  47350. */
  47351. cameraColorGradingEnabled: boolean;
  47352. /**
  47353. * Gets wether tonemapping is enabled or not.
  47354. */
  47355. /**
  47356. * Sets wether tonemapping is enabled or not
  47357. */
  47358. cameraToneMappingEnabled: boolean;
  47359. /**
  47360. * The camera exposure used on this material.
  47361. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47362. * This corresponds to a photographic exposure.
  47363. */
  47364. /**
  47365. * The camera exposure used on this material.
  47366. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47367. * This corresponds to a photographic exposure.
  47368. */
  47369. cameraExposure: number;
  47370. /**
  47371. * Gets The camera contrast used on this material.
  47372. */
  47373. /**
  47374. * Sets The camera contrast used on this material.
  47375. */
  47376. cameraContrast: number;
  47377. /**
  47378. * Gets the Color Grading 2D Lookup Texture.
  47379. */
  47380. /**
  47381. * Sets the Color Grading 2D Lookup Texture.
  47382. */
  47383. cameraColorGradingTexture: Nullable<BaseTexture>;
  47384. /**
  47385. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47386. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47387. * 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;
  47388. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47389. */
  47390. /**
  47391. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47392. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47393. * 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;
  47394. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47395. */
  47396. cameraColorCurves: Nullable<ColorCurves>;
  47397. /**
  47398. * Instantiates a new PBRMaterial instance.
  47399. *
  47400. * @param name The material name
  47401. * @param scene The scene the material will be use in.
  47402. */
  47403. constructor(name: string, scene: Scene);
  47404. /**
  47405. * Returns the name of this material class.
  47406. */
  47407. getClassName(): string;
  47408. /**
  47409. * Makes a duplicate of the current material.
  47410. * @param name - name to use for the new material.
  47411. */
  47412. clone(name: string): PBRMaterial;
  47413. /**
  47414. * Serializes this PBR Material.
  47415. * @returns - An object with the serialized material.
  47416. */
  47417. serialize(): any;
  47418. /**
  47419. * Parses a PBR Material from a serialized object.
  47420. * @param source - Serialized object.
  47421. * @param scene - BJS scene instance.
  47422. * @param rootUrl - url for the scene object
  47423. * @returns - PBRMaterial
  47424. */
  47425. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47426. }
  47427. }
  47428. declare module "babylonjs/Misc/dds" {
  47429. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47430. import { Engine } from "babylonjs/Engines/engine";
  47431. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47432. import { Nullable } from "babylonjs/types";
  47433. import { Scene } from "babylonjs/scene";
  47434. /**
  47435. * Direct draw surface info
  47436. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47437. */
  47438. export interface DDSInfo {
  47439. /**
  47440. * Width of the texture
  47441. */
  47442. width: number;
  47443. /**
  47444. * Width of the texture
  47445. */
  47446. height: number;
  47447. /**
  47448. * Number of Mipmaps for the texture
  47449. * @see https://en.wikipedia.org/wiki/Mipmap
  47450. */
  47451. mipmapCount: number;
  47452. /**
  47453. * If the textures format is a known fourCC format
  47454. * @see https://www.fourcc.org/
  47455. */
  47456. isFourCC: boolean;
  47457. /**
  47458. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47459. */
  47460. isRGB: boolean;
  47461. /**
  47462. * If the texture is a lumincance format
  47463. */
  47464. isLuminance: boolean;
  47465. /**
  47466. * If this is a cube texture
  47467. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47468. */
  47469. isCube: boolean;
  47470. /**
  47471. * If the texture is a compressed format eg. FOURCC_DXT1
  47472. */
  47473. isCompressed: boolean;
  47474. /**
  47475. * The dxgiFormat of the texture
  47476. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47477. */
  47478. dxgiFormat: number;
  47479. /**
  47480. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47481. */
  47482. textureType: number;
  47483. /**
  47484. * Sphericle polynomial created for the dds texture
  47485. */
  47486. sphericalPolynomial?: SphericalPolynomial;
  47487. }
  47488. /**
  47489. * Class used to provide DDS decompression tools
  47490. */
  47491. export class DDSTools {
  47492. /**
  47493. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47494. */
  47495. static StoreLODInAlphaChannel: boolean;
  47496. /**
  47497. * Gets DDS information from an array buffer
  47498. * @param arrayBuffer defines the array buffer to read data from
  47499. * @returns the DDS information
  47500. */
  47501. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47502. private static _FloatView;
  47503. private static _Int32View;
  47504. private static _ToHalfFloat;
  47505. private static _FromHalfFloat;
  47506. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47507. private static _GetHalfFloatRGBAArrayBuffer;
  47508. private static _GetFloatRGBAArrayBuffer;
  47509. private static _GetFloatAsUIntRGBAArrayBuffer;
  47510. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47511. private static _GetRGBAArrayBuffer;
  47512. private static _ExtractLongWordOrder;
  47513. private static _GetRGBArrayBuffer;
  47514. private static _GetLuminanceArrayBuffer;
  47515. /**
  47516. * Uploads DDS Levels to a Babylon Texture
  47517. * @hidden
  47518. */
  47519. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47520. }
  47521. module "babylonjs/Engines/engine" {
  47522. interface Engine {
  47523. /**
  47524. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47525. * @param rootUrl defines the url where the file to load is located
  47526. * @param scene defines the current scene
  47527. * @param lodScale defines scale to apply to the mip map selection
  47528. * @param lodOffset defines offset to apply to the mip map selection
  47529. * @param onLoad defines an optional callback raised when the texture is loaded
  47530. * @param onError defines an optional callback raised if there is an issue to load the texture
  47531. * @param format defines the format of the data
  47532. * @param forcedExtension defines the extension to use to pick the right loader
  47533. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47534. * @returns the cube texture as an InternalTexture
  47535. */
  47536. 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;
  47537. }
  47538. }
  47539. }
  47540. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47541. import { Nullable } from "babylonjs/types";
  47542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47543. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47544. /**
  47545. * Implementation of the DDS Texture Loader.
  47546. * @hidden
  47547. */
  47548. export class _DDSTextureLoader implements IInternalTextureLoader {
  47549. /**
  47550. * Defines wether the loader supports cascade loading the different faces.
  47551. */
  47552. readonly supportCascades: boolean;
  47553. /**
  47554. * This returns if the loader support the current file information.
  47555. * @param extension defines the file extension of the file being loaded
  47556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47557. * @param fallback defines the fallback internal texture if any
  47558. * @param isBase64 defines whether the texture is encoded as a base64
  47559. * @param isBuffer defines whether the texture data are stored as a buffer
  47560. * @returns true if the loader can load the specified file
  47561. */
  47562. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47563. /**
  47564. * Transform the url before loading if required.
  47565. * @param rootUrl the url of the texture
  47566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47567. * @returns the transformed texture
  47568. */
  47569. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47570. /**
  47571. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47572. * @param rootUrl the url of the texture
  47573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47574. * @returns the fallback texture
  47575. */
  47576. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47577. /**
  47578. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47579. * @param data contains the texture data
  47580. * @param texture defines the BabylonJS internal texture
  47581. * @param createPolynomials will be true if polynomials have been requested
  47582. * @param onLoad defines the callback to trigger once the texture is ready
  47583. * @param onError defines the callback to trigger in case of error
  47584. */
  47585. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47586. /**
  47587. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47588. * @param data contains the texture data
  47589. * @param texture defines the BabylonJS internal texture
  47590. * @param callback defines the method to call once ready to upload
  47591. */
  47592. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47593. }
  47594. }
  47595. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47596. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47597. /** @hidden */
  47598. export var rgbdEncodePixelShader: {
  47599. name: string;
  47600. shader: string;
  47601. };
  47602. }
  47603. declare module "babylonjs/Misc/environmentTextureTools" {
  47604. import { Nullable } from "babylonjs/types";
  47605. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47606. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47607. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47608. import "babylonjs/Shaders/rgbdEncode.fragment";
  47609. import "babylonjs/Shaders/rgbdDecode.fragment";
  47610. /**
  47611. * Raw texture data and descriptor sufficient for WebGL texture upload
  47612. */
  47613. export interface EnvironmentTextureInfo {
  47614. /**
  47615. * Version of the environment map
  47616. */
  47617. version: number;
  47618. /**
  47619. * Width of image
  47620. */
  47621. width: number;
  47622. /**
  47623. * Irradiance information stored in the file.
  47624. */
  47625. irradiance: any;
  47626. /**
  47627. * Specular information stored in the file.
  47628. */
  47629. specular: any;
  47630. }
  47631. /**
  47632. * Sets of helpers addressing the serialization and deserialization of environment texture
  47633. * stored in a BabylonJS env file.
  47634. * Those files are usually stored as .env files.
  47635. */
  47636. export class EnvironmentTextureTools {
  47637. /**
  47638. * Magic number identifying the env file.
  47639. */
  47640. private static _MagicBytes;
  47641. /**
  47642. * Gets the environment info from an env file.
  47643. * @param data The array buffer containing the .env bytes.
  47644. * @returns the environment file info (the json header) if successfully parsed.
  47645. */
  47646. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47647. /**
  47648. * Creates an environment texture from a loaded cube texture.
  47649. * @param texture defines the cube texture to convert in env file
  47650. * @return a promise containing the environment data if succesfull.
  47651. */
  47652. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47653. /**
  47654. * Creates a JSON representation of the spherical data.
  47655. * @param texture defines the texture containing the polynomials
  47656. * @return the JSON representation of the spherical info
  47657. */
  47658. private static _CreateEnvTextureIrradiance;
  47659. /**
  47660. * Uploads the texture info contained in the env file to the GPU.
  47661. * @param texture defines the internal texture to upload to
  47662. * @param arrayBuffer defines the buffer cotaining the data to load
  47663. * @param info defines the texture info retrieved through the GetEnvInfo method
  47664. * @returns a promise
  47665. */
  47666. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47667. /**
  47668. * Uploads the levels of image data to the GPU.
  47669. * @param texture defines the internal texture to upload to
  47670. * @param imageData defines the array buffer views of image data [mipmap][face]
  47671. * @returns a promise
  47672. */
  47673. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47674. /**
  47675. * Uploads spherical polynomials information to the texture.
  47676. * @param texture defines the texture we are trying to upload the information to
  47677. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47678. */
  47679. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47680. /** @hidden */
  47681. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47682. }
  47683. }
  47684. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47685. import { Nullable } from "babylonjs/types";
  47686. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47687. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47688. /**
  47689. * Implementation of the ENV Texture Loader.
  47690. * @hidden
  47691. */
  47692. export class _ENVTextureLoader implements IInternalTextureLoader {
  47693. /**
  47694. * Defines wether the loader supports cascade loading the different faces.
  47695. */
  47696. readonly supportCascades: boolean;
  47697. /**
  47698. * This returns if the loader support the current file information.
  47699. * @param extension defines the file extension of the file being loaded
  47700. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47701. * @param fallback defines the fallback internal texture if any
  47702. * @param isBase64 defines whether the texture is encoded as a base64
  47703. * @param isBuffer defines whether the texture data are stored as a buffer
  47704. * @returns true if the loader can load the specified file
  47705. */
  47706. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47707. /**
  47708. * Transform the url before loading if required.
  47709. * @param rootUrl the url of the texture
  47710. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47711. * @returns the transformed texture
  47712. */
  47713. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47714. /**
  47715. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47716. * @param rootUrl the url of the texture
  47717. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47718. * @returns the fallback texture
  47719. */
  47720. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47721. /**
  47722. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47723. * @param data contains the texture data
  47724. * @param texture defines the BabylonJS internal texture
  47725. * @param createPolynomials will be true if polynomials have been requested
  47726. * @param onLoad defines the callback to trigger once the texture is ready
  47727. * @param onError defines the callback to trigger in case of error
  47728. */
  47729. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47730. /**
  47731. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47732. * @param data contains the texture data
  47733. * @param texture defines the BabylonJS internal texture
  47734. * @param callback defines the method to call once ready to upload
  47735. */
  47736. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47737. }
  47738. }
  47739. declare module "babylonjs/Misc/khronosTextureContainer" {
  47740. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47741. /**
  47742. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47743. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47744. */
  47745. export class KhronosTextureContainer {
  47746. /** contents of the KTX container file */
  47747. arrayBuffer: any;
  47748. private static HEADER_LEN;
  47749. private static COMPRESSED_2D;
  47750. private static COMPRESSED_3D;
  47751. private static TEX_2D;
  47752. private static TEX_3D;
  47753. /**
  47754. * Gets the openGL type
  47755. */
  47756. glType: number;
  47757. /**
  47758. * Gets the openGL type size
  47759. */
  47760. glTypeSize: number;
  47761. /**
  47762. * Gets the openGL format
  47763. */
  47764. glFormat: number;
  47765. /**
  47766. * Gets the openGL internal format
  47767. */
  47768. glInternalFormat: number;
  47769. /**
  47770. * Gets the base internal format
  47771. */
  47772. glBaseInternalFormat: number;
  47773. /**
  47774. * Gets image width in pixel
  47775. */
  47776. pixelWidth: number;
  47777. /**
  47778. * Gets image height in pixel
  47779. */
  47780. pixelHeight: number;
  47781. /**
  47782. * Gets image depth in pixels
  47783. */
  47784. pixelDepth: number;
  47785. /**
  47786. * Gets the number of array elements
  47787. */
  47788. numberOfArrayElements: number;
  47789. /**
  47790. * Gets the number of faces
  47791. */
  47792. numberOfFaces: number;
  47793. /**
  47794. * Gets the number of mipmap levels
  47795. */
  47796. numberOfMipmapLevels: number;
  47797. /**
  47798. * Gets the bytes of key value data
  47799. */
  47800. bytesOfKeyValueData: number;
  47801. /**
  47802. * Gets the load type
  47803. */
  47804. loadType: number;
  47805. /**
  47806. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47807. */
  47808. isInvalid: boolean;
  47809. /**
  47810. * Creates a new KhronosTextureContainer
  47811. * @param arrayBuffer contents of the KTX container file
  47812. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47813. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47814. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47815. */
  47816. constructor(
  47817. /** contents of the KTX container file */
  47818. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47819. /**
  47820. * Uploads KTX content to a Babylon Texture.
  47821. * It is assumed that the texture has already been created & is currently bound
  47822. * @hidden
  47823. */
  47824. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47825. private _upload2DCompressedLevels;
  47826. }
  47827. }
  47828. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47829. import { Nullable } from "babylonjs/types";
  47830. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47831. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47832. /**
  47833. * Implementation of the KTX Texture Loader.
  47834. * @hidden
  47835. */
  47836. export class _KTXTextureLoader implements IInternalTextureLoader {
  47837. /**
  47838. * Defines wether the loader supports cascade loading the different faces.
  47839. */
  47840. readonly supportCascades: boolean;
  47841. /**
  47842. * This returns if the loader support the current file information.
  47843. * @param extension defines the file extension of the file being loaded
  47844. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47845. * @param fallback defines the fallback internal texture if any
  47846. * @param isBase64 defines whether the texture is encoded as a base64
  47847. * @param isBuffer defines whether the texture data are stored as a buffer
  47848. * @returns true if the loader can load the specified file
  47849. */
  47850. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47851. /**
  47852. * Transform the url before loading if required.
  47853. * @param rootUrl the url of the texture
  47854. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47855. * @returns the transformed texture
  47856. */
  47857. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47858. /**
  47859. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47860. * @param rootUrl the url of the texture
  47861. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47862. * @returns the fallback texture
  47863. */
  47864. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47865. /**
  47866. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47867. * @param data contains the texture data
  47868. * @param texture defines the BabylonJS internal texture
  47869. * @param createPolynomials will be true if polynomials have been requested
  47870. * @param onLoad defines the callback to trigger once the texture is ready
  47871. * @param onError defines the callback to trigger in case of error
  47872. */
  47873. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47874. /**
  47875. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47876. * @param data contains the texture data
  47877. * @param texture defines the BabylonJS internal texture
  47878. * @param callback defines the method to call once ready to upload
  47879. */
  47880. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47881. }
  47882. }
  47883. declare module "babylonjs/Helpers/sceneHelpers" {
  47884. import { Nullable } from "babylonjs/types";
  47885. import { Mesh } from "babylonjs/Meshes/mesh";
  47886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47887. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47888. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47889. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47890. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47891. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47892. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47893. import "babylonjs/Meshes/Builders/boxBuilder";
  47894. /** @hidden */
  47895. export var _forceSceneHelpersToBundle: boolean;
  47896. module "babylonjs/scene" {
  47897. interface Scene {
  47898. /**
  47899. * Creates a default light for the scene.
  47900. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47901. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47902. */
  47903. createDefaultLight(replace?: boolean): void;
  47904. /**
  47905. * Creates a default camera for the scene.
  47906. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47907. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47908. * @param replace has default false, when true replaces the active camera in the scene
  47909. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47910. */
  47911. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47912. /**
  47913. * Creates a default camera and a default light.
  47914. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47915. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47916. * @param replace has the default false, when true replaces the active camera/light in the scene
  47917. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47918. */
  47919. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47920. /**
  47921. * Creates a new sky box
  47922. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47923. * @param environmentTexture defines the texture to use as environment texture
  47924. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47925. * @param scale defines the overall scale of the skybox
  47926. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47927. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47928. * @returns a new mesh holding the sky box
  47929. */
  47930. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47931. /**
  47932. * Creates a new environment
  47933. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47934. * @param options defines the options you can use to configure the environment
  47935. * @returns the new EnvironmentHelper
  47936. */
  47937. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47938. /**
  47939. * Creates a new VREXperienceHelper
  47940. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47941. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47942. * @returns a new VREXperienceHelper
  47943. */
  47944. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47945. /**
  47946. * Creates a new XREXperienceHelper
  47947. * @see http://doc.babylonjs.com/how_to/webxr
  47948. * @returns a promise for a new XREXperienceHelper
  47949. */
  47950. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  47951. }
  47952. }
  47953. }
  47954. declare module "babylonjs/Helpers/videoDome" {
  47955. import { Scene } from "babylonjs/scene";
  47956. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47957. import { Mesh } from "babylonjs/Meshes/mesh";
  47958. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  47959. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  47960. import "babylonjs/Meshes/Builders/sphereBuilder";
  47961. /**
  47962. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47963. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47964. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47965. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47966. */
  47967. export class VideoDome extends TransformNode {
  47968. /**
  47969. * Define the video source as a Monoscopic panoramic 360 video.
  47970. */
  47971. static readonly MODE_MONOSCOPIC: number;
  47972. /**
  47973. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47974. */
  47975. static readonly MODE_TOPBOTTOM: number;
  47976. /**
  47977. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47978. */
  47979. static readonly MODE_SIDEBYSIDE: number;
  47980. private _useDirectMapping;
  47981. /**
  47982. * The video texture being displayed on the sphere
  47983. */
  47984. protected _videoTexture: VideoTexture;
  47985. /**
  47986. * Gets the video texture being displayed on the sphere
  47987. */
  47988. readonly videoTexture: VideoTexture;
  47989. /**
  47990. * The skybox material
  47991. */
  47992. protected _material: BackgroundMaterial;
  47993. /**
  47994. * The surface used for the skybox
  47995. */
  47996. protected _mesh: Mesh;
  47997. /**
  47998. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47999. * Also see the options.resolution property.
  48000. */
  48001. fovMultiplier: number;
  48002. private _videoMode;
  48003. /**
  48004. * Gets or set the current video mode for the video. It can be:
  48005. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48006. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48007. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48008. */
  48009. videoMode: number;
  48010. /**
  48011. * Oberserver used in Stereoscopic VR Mode.
  48012. */
  48013. private _onBeforeCameraRenderObserver;
  48014. /**
  48015. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48016. * @param name Element's name, child elements will append suffixes for their own names.
  48017. * @param urlsOrVideo defines the url(s) or the video element to use
  48018. * @param options An object containing optional or exposed sub element properties
  48019. */
  48020. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48021. resolution?: number;
  48022. clickToPlay?: boolean;
  48023. autoPlay?: boolean;
  48024. loop?: boolean;
  48025. size?: number;
  48026. poster?: string;
  48027. faceForward?: boolean;
  48028. useDirectMapping?: boolean;
  48029. }, scene: Scene);
  48030. private _changeVideoMode;
  48031. /**
  48032. * Releases resources associated with this node.
  48033. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48034. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48035. */
  48036. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48037. }
  48038. }
  48039. declare module "babylonjs/Helpers/index" {
  48040. export * from "babylonjs/Helpers/environmentHelper";
  48041. export * from "babylonjs/Helpers/photoDome";
  48042. export * from "babylonjs/Helpers/sceneHelpers";
  48043. export * from "babylonjs/Helpers/videoDome";
  48044. }
  48045. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48046. import { PerfCounter } from "babylonjs/Misc/tools";
  48047. import { IDisposable } from "babylonjs/scene";
  48048. import { Engine } from "babylonjs/Engines/engine";
  48049. /**
  48050. * This class can be used to get instrumentation data from a Babylon engine
  48051. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48052. */
  48053. export class EngineInstrumentation implements IDisposable {
  48054. /**
  48055. * Define the instrumented engine.
  48056. */
  48057. engine: Engine;
  48058. private _captureGPUFrameTime;
  48059. private _gpuFrameTimeToken;
  48060. private _gpuFrameTime;
  48061. private _captureShaderCompilationTime;
  48062. private _shaderCompilationTime;
  48063. private _onBeginFrameObserver;
  48064. private _onEndFrameObserver;
  48065. private _onBeforeShaderCompilationObserver;
  48066. private _onAfterShaderCompilationObserver;
  48067. /**
  48068. * Gets the perf counter used for GPU frame time
  48069. */
  48070. readonly gpuFrameTimeCounter: PerfCounter;
  48071. /**
  48072. * Gets the GPU frame time capture status
  48073. */
  48074. /**
  48075. * Enable or disable the GPU frame time capture
  48076. */
  48077. captureGPUFrameTime: boolean;
  48078. /**
  48079. * Gets the perf counter used for shader compilation time
  48080. */
  48081. readonly shaderCompilationTimeCounter: PerfCounter;
  48082. /**
  48083. * Gets the shader compilation time capture status
  48084. */
  48085. /**
  48086. * Enable or disable the shader compilation time capture
  48087. */
  48088. captureShaderCompilationTime: boolean;
  48089. /**
  48090. * Instantiates a new engine instrumentation.
  48091. * This class can be used to get instrumentation data from a Babylon engine
  48092. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48093. * @param engine Defines the engine to instrument
  48094. */
  48095. constructor(
  48096. /**
  48097. * Define the instrumented engine.
  48098. */
  48099. engine: Engine);
  48100. /**
  48101. * Dispose and release associated resources.
  48102. */
  48103. dispose(): void;
  48104. }
  48105. }
  48106. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48107. import { PerfCounter } from "babylonjs/Misc/tools";
  48108. import { Scene, IDisposable } from "babylonjs/scene";
  48109. /**
  48110. * This class can be used to get instrumentation data from a Babylon engine
  48111. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48112. */
  48113. export class SceneInstrumentation implements IDisposable {
  48114. /**
  48115. * Defines the scene to instrument
  48116. */
  48117. scene: Scene;
  48118. private _captureActiveMeshesEvaluationTime;
  48119. private _activeMeshesEvaluationTime;
  48120. private _captureRenderTargetsRenderTime;
  48121. private _renderTargetsRenderTime;
  48122. private _captureFrameTime;
  48123. private _frameTime;
  48124. private _captureRenderTime;
  48125. private _renderTime;
  48126. private _captureInterFrameTime;
  48127. private _interFrameTime;
  48128. private _captureParticlesRenderTime;
  48129. private _particlesRenderTime;
  48130. private _captureSpritesRenderTime;
  48131. private _spritesRenderTime;
  48132. private _capturePhysicsTime;
  48133. private _physicsTime;
  48134. private _captureAnimationsTime;
  48135. private _animationsTime;
  48136. private _captureCameraRenderTime;
  48137. private _cameraRenderTime;
  48138. private _onBeforeActiveMeshesEvaluationObserver;
  48139. private _onAfterActiveMeshesEvaluationObserver;
  48140. private _onBeforeRenderTargetsRenderObserver;
  48141. private _onAfterRenderTargetsRenderObserver;
  48142. private _onAfterRenderObserver;
  48143. private _onBeforeDrawPhaseObserver;
  48144. private _onAfterDrawPhaseObserver;
  48145. private _onBeforeAnimationsObserver;
  48146. private _onBeforeParticlesRenderingObserver;
  48147. private _onAfterParticlesRenderingObserver;
  48148. private _onBeforeSpritesRenderingObserver;
  48149. private _onAfterSpritesRenderingObserver;
  48150. private _onBeforePhysicsObserver;
  48151. private _onAfterPhysicsObserver;
  48152. private _onAfterAnimationsObserver;
  48153. private _onBeforeCameraRenderObserver;
  48154. private _onAfterCameraRenderObserver;
  48155. /**
  48156. * Gets the perf counter used for active meshes evaluation time
  48157. */
  48158. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48159. /**
  48160. * Gets the active meshes evaluation time capture status
  48161. */
  48162. /**
  48163. * Enable or disable the active meshes evaluation time capture
  48164. */
  48165. captureActiveMeshesEvaluationTime: boolean;
  48166. /**
  48167. * Gets the perf counter used for render targets render time
  48168. */
  48169. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48170. /**
  48171. * Gets the render targets render time capture status
  48172. */
  48173. /**
  48174. * Enable or disable the render targets render time capture
  48175. */
  48176. captureRenderTargetsRenderTime: boolean;
  48177. /**
  48178. * Gets the perf counter used for particles render time
  48179. */
  48180. readonly particlesRenderTimeCounter: PerfCounter;
  48181. /**
  48182. * Gets the particles render time capture status
  48183. */
  48184. /**
  48185. * Enable or disable the particles render time capture
  48186. */
  48187. captureParticlesRenderTime: boolean;
  48188. /**
  48189. * Gets the perf counter used for sprites render time
  48190. */
  48191. readonly spritesRenderTimeCounter: PerfCounter;
  48192. /**
  48193. * Gets the sprites render time capture status
  48194. */
  48195. /**
  48196. * Enable or disable the sprites render time capture
  48197. */
  48198. captureSpritesRenderTime: boolean;
  48199. /**
  48200. * Gets the perf counter used for physics time
  48201. */
  48202. readonly physicsTimeCounter: PerfCounter;
  48203. /**
  48204. * Gets the physics time capture status
  48205. */
  48206. /**
  48207. * Enable or disable the physics time capture
  48208. */
  48209. capturePhysicsTime: boolean;
  48210. /**
  48211. * Gets the perf counter used for animations time
  48212. */
  48213. readonly animationsTimeCounter: PerfCounter;
  48214. /**
  48215. * Gets the animations time capture status
  48216. */
  48217. /**
  48218. * Enable or disable the animations time capture
  48219. */
  48220. captureAnimationsTime: boolean;
  48221. /**
  48222. * Gets the perf counter used for frame time capture
  48223. */
  48224. readonly frameTimeCounter: PerfCounter;
  48225. /**
  48226. * Gets the frame time capture status
  48227. */
  48228. /**
  48229. * Enable or disable the frame time capture
  48230. */
  48231. captureFrameTime: boolean;
  48232. /**
  48233. * Gets the perf counter used for inter-frames time capture
  48234. */
  48235. readonly interFrameTimeCounter: PerfCounter;
  48236. /**
  48237. * Gets the inter-frames time capture status
  48238. */
  48239. /**
  48240. * Enable or disable the inter-frames time capture
  48241. */
  48242. captureInterFrameTime: boolean;
  48243. /**
  48244. * Gets the perf counter used for render time capture
  48245. */
  48246. readonly renderTimeCounter: PerfCounter;
  48247. /**
  48248. * Gets the render time capture status
  48249. */
  48250. /**
  48251. * Enable or disable the render time capture
  48252. */
  48253. captureRenderTime: boolean;
  48254. /**
  48255. * Gets the perf counter used for camera render time capture
  48256. */
  48257. readonly cameraRenderTimeCounter: PerfCounter;
  48258. /**
  48259. * Gets the camera render time capture status
  48260. */
  48261. /**
  48262. * Enable or disable the camera render time capture
  48263. */
  48264. captureCameraRenderTime: boolean;
  48265. /**
  48266. * Gets the perf counter used for draw calls
  48267. */
  48268. readonly drawCallsCounter: PerfCounter;
  48269. /**
  48270. * Instantiates a new scene instrumentation.
  48271. * This class can be used to get instrumentation data from a Babylon engine
  48272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48273. * @param scene Defines the scene to instrument
  48274. */
  48275. constructor(
  48276. /**
  48277. * Defines the scene to instrument
  48278. */
  48279. scene: Scene);
  48280. /**
  48281. * Dispose and release associated resources.
  48282. */
  48283. dispose(): void;
  48284. }
  48285. }
  48286. declare module "babylonjs/Instrumentation/index" {
  48287. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48288. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48289. export * from "babylonjs/Instrumentation/timeToken";
  48290. }
  48291. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48292. /** @hidden */
  48293. export var glowMapGenerationPixelShader: {
  48294. name: string;
  48295. shader: string;
  48296. };
  48297. }
  48298. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48299. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48300. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48301. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48302. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48303. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48304. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48305. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48306. /** @hidden */
  48307. export var glowMapGenerationVertexShader: {
  48308. name: string;
  48309. shader: string;
  48310. };
  48311. }
  48312. declare module "babylonjs/Layers/effectLayer" {
  48313. import { Observable } from "babylonjs/Misc/observable";
  48314. import { Nullable } from "babylonjs/types";
  48315. import { Camera } from "babylonjs/Cameras/camera";
  48316. import { Scene } from "babylonjs/scene";
  48317. import { Color4, ISize } from "babylonjs/Maths/math";
  48318. import { Engine } from "babylonjs/Engines/engine";
  48319. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48321. import { Mesh } from "babylonjs/Meshes/mesh";
  48322. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48324. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48325. import { Effect } from "babylonjs/Materials/effect";
  48326. import { Material } from "babylonjs/Materials/material";
  48327. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48328. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48329. /**
  48330. * Effect layer options. This helps customizing the behaviour
  48331. * of the effect layer.
  48332. */
  48333. export interface IEffectLayerOptions {
  48334. /**
  48335. * Multiplication factor apply to the canvas size to compute the render target size
  48336. * used to generated the objects (the smaller the faster).
  48337. */
  48338. mainTextureRatio: number;
  48339. /**
  48340. * Enforces a fixed size texture to ensure effect stability across devices.
  48341. */
  48342. mainTextureFixedSize?: number;
  48343. /**
  48344. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48345. */
  48346. alphaBlendingMode: number;
  48347. /**
  48348. * The camera attached to the layer.
  48349. */
  48350. camera: Nullable<Camera>;
  48351. /**
  48352. * The rendering group to draw the layer in.
  48353. */
  48354. renderingGroupId: number;
  48355. }
  48356. /**
  48357. * The effect layer Helps adding post process effect blended with the main pass.
  48358. *
  48359. * This can be for instance use to generate glow or higlight effects on the scene.
  48360. *
  48361. * The effect layer class can not be used directly and is intented to inherited from to be
  48362. * customized per effects.
  48363. */
  48364. export abstract class EffectLayer {
  48365. private _vertexBuffers;
  48366. private _indexBuffer;
  48367. private _cachedDefines;
  48368. private _effectLayerMapGenerationEffect;
  48369. private _effectLayerOptions;
  48370. private _mergeEffect;
  48371. protected _scene: Scene;
  48372. protected _engine: Engine;
  48373. protected _maxSize: number;
  48374. protected _mainTextureDesiredSize: ISize;
  48375. protected _mainTexture: RenderTargetTexture;
  48376. protected _shouldRender: boolean;
  48377. protected _postProcesses: PostProcess[];
  48378. protected _textures: BaseTexture[];
  48379. protected _emissiveTextureAndColor: {
  48380. texture: Nullable<BaseTexture>;
  48381. color: Color4;
  48382. };
  48383. /**
  48384. * The name of the layer
  48385. */
  48386. name: string;
  48387. /**
  48388. * The clear color of the texture used to generate the glow map.
  48389. */
  48390. neutralColor: Color4;
  48391. /**
  48392. * Specifies wether the highlight layer is enabled or not.
  48393. */
  48394. isEnabled: boolean;
  48395. /**
  48396. * Gets the camera attached to the layer.
  48397. */
  48398. readonly camera: Nullable<Camera>;
  48399. /**
  48400. * Gets the rendering group id the layer should render in.
  48401. */
  48402. readonly renderingGroupId: number;
  48403. /**
  48404. * An event triggered when the effect layer has been disposed.
  48405. */
  48406. onDisposeObservable: Observable<EffectLayer>;
  48407. /**
  48408. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48409. */
  48410. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48411. /**
  48412. * An event triggered when the generated texture is being merged in the scene.
  48413. */
  48414. onBeforeComposeObservable: Observable<EffectLayer>;
  48415. /**
  48416. * An event triggered when the generated texture has been merged in the scene.
  48417. */
  48418. onAfterComposeObservable: Observable<EffectLayer>;
  48419. /**
  48420. * An event triggered when the efffect layer changes its size.
  48421. */
  48422. onSizeChangedObservable: Observable<EffectLayer>;
  48423. /** @hidden */
  48424. static _SceneComponentInitialization: (scene: Scene) => void;
  48425. /**
  48426. * Instantiates a new effect Layer and references it in the scene.
  48427. * @param name The name of the layer
  48428. * @param scene The scene to use the layer in
  48429. */
  48430. constructor(
  48431. /** The Friendly of the effect in the scene */
  48432. name: string, scene: Scene);
  48433. /**
  48434. * Get the effect name of the layer.
  48435. * @return The effect name
  48436. */
  48437. abstract getEffectName(): string;
  48438. /**
  48439. * Checks for the readiness of the element composing the layer.
  48440. * @param subMesh the mesh to check for
  48441. * @param useInstances specify wether or not to use instances to render the mesh
  48442. * @return true if ready otherwise, false
  48443. */
  48444. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48445. /**
  48446. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48447. * @returns true if the effect requires stencil during the main canvas render pass.
  48448. */
  48449. abstract needStencil(): boolean;
  48450. /**
  48451. * Create the merge effect. This is the shader use to blit the information back
  48452. * to the main canvas at the end of the scene rendering.
  48453. * @returns The effect containing the shader used to merge the effect on the main canvas
  48454. */
  48455. protected abstract _createMergeEffect(): Effect;
  48456. /**
  48457. * Creates the render target textures and post processes used in the effect layer.
  48458. */
  48459. protected abstract _createTextureAndPostProcesses(): void;
  48460. /**
  48461. * Implementation specific of rendering the generating effect on the main canvas.
  48462. * @param effect The effect used to render through
  48463. */
  48464. protected abstract _internalRender(effect: Effect): void;
  48465. /**
  48466. * Sets the required values for both the emissive texture and and the main color.
  48467. */
  48468. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48469. /**
  48470. * Free any resources and references associated to a mesh.
  48471. * Internal use
  48472. * @param mesh The mesh to free.
  48473. */
  48474. abstract _disposeMesh(mesh: Mesh): void;
  48475. /**
  48476. * Serializes this layer (Glow or Highlight for example)
  48477. * @returns a serialized layer object
  48478. */
  48479. abstract serialize?(): any;
  48480. /**
  48481. * Initializes the effect layer with the required options.
  48482. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48483. */
  48484. protected _init(options: Partial<IEffectLayerOptions>): void;
  48485. /**
  48486. * Generates the index buffer of the full screen quad blending to the main canvas.
  48487. */
  48488. private _generateIndexBuffer;
  48489. /**
  48490. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48491. */
  48492. private _genrateVertexBuffer;
  48493. /**
  48494. * Sets the main texture desired size which is the closest power of two
  48495. * of the engine canvas size.
  48496. */
  48497. private _setMainTextureSize;
  48498. /**
  48499. * Creates the main texture for the effect layer.
  48500. */
  48501. protected _createMainTexture(): void;
  48502. /**
  48503. * Adds specific effects defines.
  48504. * @param defines The defines to add specifics to.
  48505. */
  48506. protected _addCustomEffectDefines(defines: string[]): void;
  48507. /**
  48508. * Checks for the readiness of the element composing the layer.
  48509. * @param subMesh the mesh to check for
  48510. * @param useInstances specify wether or not to use instances to render the mesh
  48511. * @param emissiveTexture the associated emissive texture used to generate the glow
  48512. * @return true if ready otherwise, false
  48513. */
  48514. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48515. /**
  48516. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48517. */
  48518. render(): void;
  48519. /**
  48520. * Determine if a given mesh will be used in the current effect.
  48521. * @param mesh mesh to test
  48522. * @returns true if the mesh will be used
  48523. */
  48524. hasMesh(mesh: AbstractMesh): boolean;
  48525. /**
  48526. * Returns true if the layer contains information to display, otherwise false.
  48527. * @returns true if the glow layer should be rendered
  48528. */
  48529. shouldRender(): boolean;
  48530. /**
  48531. * Returns true if the mesh should render, otherwise false.
  48532. * @param mesh The mesh to render
  48533. * @returns true if it should render otherwise false
  48534. */
  48535. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48536. /**
  48537. * Returns true if the mesh can be rendered, otherwise false.
  48538. * @param mesh The mesh to render
  48539. * @param material The material used on the mesh
  48540. * @returns true if it can be rendered otherwise false
  48541. */
  48542. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48543. /**
  48544. * Returns true if the mesh should render, otherwise false.
  48545. * @param mesh The mesh to render
  48546. * @returns true if it should render otherwise false
  48547. */
  48548. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48549. /**
  48550. * Renders the submesh passed in parameter to the generation map.
  48551. */
  48552. protected _renderSubMesh(subMesh: SubMesh): void;
  48553. /**
  48554. * Rebuild the required buffers.
  48555. * @hidden Internal use only.
  48556. */
  48557. _rebuild(): void;
  48558. /**
  48559. * Dispose only the render target textures and post process.
  48560. */
  48561. private _disposeTextureAndPostProcesses;
  48562. /**
  48563. * Dispose the highlight layer and free resources.
  48564. */
  48565. dispose(): void;
  48566. /**
  48567. * Gets the class name of the effect layer
  48568. * @returns the string with the class name of the effect layer
  48569. */
  48570. getClassName(): string;
  48571. /**
  48572. * Creates an effect layer from parsed effect layer data
  48573. * @param parsedEffectLayer defines effect layer data
  48574. * @param scene defines the current scene
  48575. * @param rootUrl defines the root URL containing the effect layer information
  48576. * @returns a parsed effect Layer
  48577. */
  48578. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48579. }
  48580. }
  48581. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48582. import { Scene } from "babylonjs/scene";
  48583. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48584. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48585. import { AbstractScene } from "babylonjs/abstractScene";
  48586. module "babylonjs/abstractScene" {
  48587. interface AbstractScene {
  48588. /**
  48589. * The list of effect layers (highlights/glow) added to the scene
  48590. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48591. * @see http://doc.babylonjs.com/how_to/glow_layer
  48592. */
  48593. effectLayers: Array<EffectLayer>;
  48594. /**
  48595. * Removes the given effect layer from this scene.
  48596. * @param toRemove defines the effect layer to remove
  48597. * @returns the index of the removed effect layer
  48598. */
  48599. removeEffectLayer(toRemove: EffectLayer): number;
  48600. /**
  48601. * Adds the given effect layer to this scene
  48602. * @param newEffectLayer defines the effect layer to add
  48603. */
  48604. addEffectLayer(newEffectLayer: EffectLayer): void;
  48605. }
  48606. }
  48607. /**
  48608. * Defines the layer scene component responsible to manage any effect layers
  48609. * in a given scene.
  48610. */
  48611. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48612. /**
  48613. * The component name helpfull to identify the component in the list of scene components.
  48614. */
  48615. readonly name: string;
  48616. /**
  48617. * The scene the component belongs to.
  48618. */
  48619. scene: Scene;
  48620. private _engine;
  48621. private _renderEffects;
  48622. private _needStencil;
  48623. private _previousStencilState;
  48624. /**
  48625. * Creates a new instance of the component for the given scene
  48626. * @param scene Defines the scene to register the component in
  48627. */
  48628. constructor(scene: Scene);
  48629. /**
  48630. * Registers the component in a given scene
  48631. */
  48632. register(): void;
  48633. /**
  48634. * Rebuilds the elements related to this component in case of
  48635. * context lost for instance.
  48636. */
  48637. rebuild(): void;
  48638. /**
  48639. * Serializes the component data to the specified json object
  48640. * @param serializationObject The object to serialize to
  48641. */
  48642. serialize(serializationObject: any): void;
  48643. /**
  48644. * Adds all the element from the container to the scene
  48645. * @param container the container holding the elements
  48646. */
  48647. addFromContainer(container: AbstractScene): void;
  48648. /**
  48649. * Removes all the elements in the container from the scene
  48650. * @param container contains the elements to remove
  48651. * @param dispose if the removed element should be disposed (default: false)
  48652. */
  48653. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48654. /**
  48655. * Disposes the component and the associated ressources.
  48656. */
  48657. dispose(): void;
  48658. private _isReadyForMesh;
  48659. private _renderMainTexture;
  48660. private _setStencil;
  48661. private _setStencilBack;
  48662. private _draw;
  48663. private _drawCamera;
  48664. private _drawRenderingGroup;
  48665. }
  48666. }
  48667. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48668. /** @hidden */
  48669. export var glowMapMergePixelShader: {
  48670. name: string;
  48671. shader: string;
  48672. };
  48673. }
  48674. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48675. /** @hidden */
  48676. export var glowMapMergeVertexShader: {
  48677. name: string;
  48678. shader: string;
  48679. };
  48680. }
  48681. declare module "babylonjs/Layers/glowLayer" {
  48682. import { Nullable } from "babylonjs/types";
  48683. import { Camera } from "babylonjs/Cameras/camera";
  48684. import { Scene } from "babylonjs/scene";
  48685. import { Color4 } from "babylonjs/Maths/math";
  48686. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48687. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48688. import { Mesh } from "babylonjs/Meshes/mesh";
  48689. import { Texture } from "babylonjs/Materials/Textures/texture";
  48690. import { Effect } from "babylonjs/Materials/effect";
  48691. import { Material } from "babylonjs/Materials/material";
  48692. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48693. import "babylonjs/Shaders/glowMapMerge.fragment";
  48694. import "babylonjs/Shaders/glowMapMerge.vertex";
  48695. import "babylonjs/Layers/effectLayerSceneComponent";
  48696. module "babylonjs/abstractScene" {
  48697. interface AbstractScene {
  48698. /**
  48699. * Return a the first highlight layer of the scene with a given name.
  48700. * @param name The name of the highlight layer to look for.
  48701. * @return The highlight layer if found otherwise null.
  48702. */
  48703. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48704. }
  48705. }
  48706. /**
  48707. * Glow layer options. This helps customizing the behaviour
  48708. * of the glow layer.
  48709. */
  48710. export interface IGlowLayerOptions {
  48711. /**
  48712. * Multiplication factor apply to the canvas size to compute the render target size
  48713. * used to generated the glowing objects (the smaller the faster).
  48714. */
  48715. mainTextureRatio: number;
  48716. /**
  48717. * Enforces a fixed size texture to ensure resize independant blur.
  48718. */
  48719. mainTextureFixedSize?: number;
  48720. /**
  48721. * How big is the kernel of the blur texture.
  48722. */
  48723. blurKernelSize: number;
  48724. /**
  48725. * The camera attached to the layer.
  48726. */
  48727. camera: Nullable<Camera>;
  48728. /**
  48729. * Enable MSAA by chosing the number of samples.
  48730. */
  48731. mainTextureSamples?: number;
  48732. /**
  48733. * The rendering group to draw the layer in.
  48734. */
  48735. renderingGroupId: number;
  48736. }
  48737. /**
  48738. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48739. *
  48740. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48741. * glowy meshes to your scene.
  48742. *
  48743. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48744. */
  48745. export class GlowLayer extends EffectLayer {
  48746. /**
  48747. * Effect Name of the layer.
  48748. */
  48749. static readonly EffectName: string;
  48750. /**
  48751. * The default blur kernel size used for the glow.
  48752. */
  48753. static DefaultBlurKernelSize: number;
  48754. /**
  48755. * The default texture size ratio used for the glow.
  48756. */
  48757. static DefaultTextureRatio: number;
  48758. /**
  48759. * Sets the kernel size of the blur.
  48760. */
  48761. /**
  48762. * Gets the kernel size of the blur.
  48763. */
  48764. blurKernelSize: number;
  48765. /**
  48766. * Sets the glow intensity.
  48767. */
  48768. /**
  48769. * Gets the glow intensity.
  48770. */
  48771. intensity: number;
  48772. private _options;
  48773. private _intensity;
  48774. private _horizontalBlurPostprocess1;
  48775. private _verticalBlurPostprocess1;
  48776. private _horizontalBlurPostprocess2;
  48777. private _verticalBlurPostprocess2;
  48778. private _blurTexture1;
  48779. private _blurTexture2;
  48780. private _postProcesses1;
  48781. private _postProcesses2;
  48782. private _includedOnlyMeshes;
  48783. private _excludedMeshes;
  48784. /**
  48785. * Callback used to let the user override the color selection on a per mesh basis
  48786. */
  48787. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48788. /**
  48789. * Callback used to let the user override the texture selection on a per mesh basis
  48790. */
  48791. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48792. /**
  48793. * Instantiates a new glow Layer and references it to the scene.
  48794. * @param name The name of the layer
  48795. * @param scene The scene to use the layer in
  48796. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48797. */
  48798. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48799. /**
  48800. * Get the effect name of the layer.
  48801. * @return The effect name
  48802. */
  48803. getEffectName(): string;
  48804. /**
  48805. * Create the merge effect. This is the shader use to blit the information back
  48806. * to the main canvas at the end of the scene rendering.
  48807. */
  48808. protected _createMergeEffect(): Effect;
  48809. /**
  48810. * Creates the render target textures and post processes used in the glow layer.
  48811. */
  48812. protected _createTextureAndPostProcesses(): void;
  48813. /**
  48814. * Checks for the readiness of the element composing the layer.
  48815. * @param subMesh the mesh to check for
  48816. * @param useInstances specify wether or not to use instances to render the mesh
  48817. * @param emissiveTexture the associated emissive texture used to generate the glow
  48818. * @return true if ready otherwise, false
  48819. */
  48820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48821. /**
  48822. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48823. */
  48824. needStencil(): boolean;
  48825. /**
  48826. * Returns true if the mesh can be rendered, otherwise false.
  48827. * @param mesh The mesh to render
  48828. * @param material The material used on the mesh
  48829. * @returns true if it can be rendered otherwise false
  48830. */
  48831. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48832. /**
  48833. * Implementation specific of rendering the generating effect on the main canvas.
  48834. * @param effect The effect used to render through
  48835. */
  48836. protected _internalRender(effect: Effect): void;
  48837. /**
  48838. * Sets the required values for both the emissive texture and and the main color.
  48839. */
  48840. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48841. /**
  48842. * Returns true if the mesh should render, otherwise false.
  48843. * @param mesh The mesh to render
  48844. * @returns true if it should render otherwise false
  48845. */
  48846. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48847. /**
  48848. * Adds specific effects defines.
  48849. * @param defines The defines to add specifics to.
  48850. */
  48851. protected _addCustomEffectDefines(defines: string[]): void;
  48852. /**
  48853. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48854. * @param mesh The mesh to exclude from the glow layer
  48855. */
  48856. addExcludedMesh(mesh: Mesh): void;
  48857. /**
  48858. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48859. * @param mesh The mesh to remove
  48860. */
  48861. removeExcludedMesh(mesh: Mesh): void;
  48862. /**
  48863. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48864. * @param mesh The mesh to include in the glow layer
  48865. */
  48866. addIncludedOnlyMesh(mesh: Mesh): void;
  48867. /**
  48868. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48869. * @param mesh The mesh to remove
  48870. */
  48871. removeIncludedOnlyMesh(mesh: Mesh): void;
  48872. /**
  48873. * Determine if a given mesh will be used in the glow layer
  48874. * @param mesh The mesh to test
  48875. * @returns true if the mesh will be highlighted by the current glow layer
  48876. */
  48877. hasMesh(mesh: AbstractMesh): boolean;
  48878. /**
  48879. * Free any resources and references associated to a mesh.
  48880. * Internal use
  48881. * @param mesh The mesh to free.
  48882. * @hidden
  48883. */
  48884. _disposeMesh(mesh: Mesh): void;
  48885. /**
  48886. * Gets the class name of the effect layer
  48887. * @returns the string with the class name of the effect layer
  48888. */
  48889. getClassName(): string;
  48890. /**
  48891. * Serializes this glow layer
  48892. * @returns a serialized glow layer object
  48893. */
  48894. serialize(): any;
  48895. /**
  48896. * Creates a Glow Layer from parsed glow layer data
  48897. * @param parsedGlowLayer defines glow layer data
  48898. * @param scene defines the current scene
  48899. * @param rootUrl defines the root URL containing the glow layer information
  48900. * @returns a parsed Glow Layer
  48901. */
  48902. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48903. }
  48904. }
  48905. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48906. /** @hidden */
  48907. export var glowBlurPostProcessPixelShader: {
  48908. name: string;
  48909. shader: string;
  48910. };
  48911. }
  48912. declare module "babylonjs/Layers/highlightLayer" {
  48913. import { Observable } from "babylonjs/Misc/observable";
  48914. import { Nullable } from "babylonjs/types";
  48915. import { Camera } from "babylonjs/Cameras/camera";
  48916. import { Scene } from "babylonjs/scene";
  48917. import { Color3, Color4 } from "babylonjs/Maths/math";
  48918. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48920. import { Mesh } from "babylonjs/Meshes/mesh";
  48921. import { Effect } from "babylonjs/Materials/effect";
  48922. import { Material } from "babylonjs/Materials/material";
  48923. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48924. import "babylonjs/Shaders/glowMapMerge.fragment";
  48925. import "babylonjs/Shaders/glowMapMerge.vertex";
  48926. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48927. module "babylonjs/abstractScene" {
  48928. interface AbstractScene {
  48929. /**
  48930. * Return a the first highlight layer of the scene with a given name.
  48931. * @param name The name of the highlight layer to look for.
  48932. * @return The highlight layer if found otherwise null.
  48933. */
  48934. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48935. }
  48936. }
  48937. /**
  48938. * Highlight layer options. This helps customizing the behaviour
  48939. * of the highlight layer.
  48940. */
  48941. export interface IHighlightLayerOptions {
  48942. /**
  48943. * Multiplication factor apply to the canvas size to compute the render target size
  48944. * used to generated the glowing objects (the smaller the faster).
  48945. */
  48946. mainTextureRatio: number;
  48947. /**
  48948. * Enforces a fixed size texture to ensure resize independant blur.
  48949. */
  48950. mainTextureFixedSize?: number;
  48951. /**
  48952. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48953. * of the picture to blur (the smaller the faster).
  48954. */
  48955. blurTextureSizeRatio: number;
  48956. /**
  48957. * How big in texel of the blur texture is the vertical blur.
  48958. */
  48959. blurVerticalSize: number;
  48960. /**
  48961. * How big in texel of the blur texture is the horizontal blur.
  48962. */
  48963. blurHorizontalSize: number;
  48964. /**
  48965. * Alpha blending mode used to apply the blur. Default is combine.
  48966. */
  48967. alphaBlendingMode: number;
  48968. /**
  48969. * The camera attached to the layer.
  48970. */
  48971. camera: Nullable<Camera>;
  48972. /**
  48973. * Should we display highlight as a solid stroke?
  48974. */
  48975. isStroke?: boolean;
  48976. /**
  48977. * The rendering group to draw the layer in.
  48978. */
  48979. renderingGroupId: number;
  48980. }
  48981. /**
  48982. * The highlight layer Helps adding a glow effect around a mesh.
  48983. *
  48984. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48985. * glowy meshes to your scene.
  48986. *
  48987. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48988. */
  48989. export class HighlightLayer extends EffectLayer {
  48990. name: string;
  48991. /**
  48992. * Effect Name of the highlight layer.
  48993. */
  48994. static readonly EffectName: string;
  48995. /**
  48996. * The neutral color used during the preparation of the glow effect.
  48997. * This is black by default as the blend operation is a blend operation.
  48998. */
  48999. static NeutralColor: Color4;
  49000. /**
  49001. * Stencil value used for glowing meshes.
  49002. */
  49003. static GlowingMeshStencilReference: number;
  49004. /**
  49005. * Stencil value used for the other meshes in the scene.
  49006. */
  49007. static NormalMeshStencilReference: number;
  49008. /**
  49009. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49010. */
  49011. innerGlow: boolean;
  49012. /**
  49013. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49014. */
  49015. outerGlow: boolean;
  49016. /**
  49017. * Specifies the horizontal size of the blur.
  49018. */
  49019. /**
  49020. * Gets the horizontal size of the blur.
  49021. */
  49022. blurHorizontalSize: number;
  49023. /**
  49024. * Specifies the vertical size of the blur.
  49025. */
  49026. /**
  49027. * Gets the vertical size of the blur.
  49028. */
  49029. blurVerticalSize: number;
  49030. /**
  49031. * An event triggered when the highlight layer is being blurred.
  49032. */
  49033. onBeforeBlurObservable: Observable<HighlightLayer>;
  49034. /**
  49035. * An event triggered when the highlight layer has been blurred.
  49036. */
  49037. onAfterBlurObservable: Observable<HighlightLayer>;
  49038. private _instanceGlowingMeshStencilReference;
  49039. private _options;
  49040. private _downSamplePostprocess;
  49041. private _horizontalBlurPostprocess;
  49042. private _verticalBlurPostprocess;
  49043. private _blurTexture;
  49044. private _meshes;
  49045. private _excludedMeshes;
  49046. /**
  49047. * Instantiates a new highlight Layer and references it to the scene..
  49048. * @param name The name of the layer
  49049. * @param scene The scene to use the layer in
  49050. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49051. */
  49052. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49053. /**
  49054. * Get the effect name of the layer.
  49055. * @return The effect name
  49056. */
  49057. getEffectName(): string;
  49058. /**
  49059. * Create the merge effect. This is the shader use to blit the information back
  49060. * to the main canvas at the end of the scene rendering.
  49061. */
  49062. protected _createMergeEffect(): Effect;
  49063. /**
  49064. * Creates the render target textures and post processes used in the highlight layer.
  49065. */
  49066. protected _createTextureAndPostProcesses(): void;
  49067. /**
  49068. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49069. */
  49070. needStencil(): boolean;
  49071. /**
  49072. * Checks for the readiness of the element composing the layer.
  49073. * @param subMesh the mesh to check for
  49074. * @param useInstances specify wether or not to use instances to render the mesh
  49075. * @param emissiveTexture the associated emissive texture used to generate the glow
  49076. * @return true if ready otherwise, false
  49077. */
  49078. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49079. /**
  49080. * Implementation specific of rendering the generating effect on the main canvas.
  49081. * @param effect The effect used to render through
  49082. */
  49083. protected _internalRender(effect: Effect): void;
  49084. /**
  49085. * Returns true if the layer contains information to display, otherwise false.
  49086. */
  49087. shouldRender(): boolean;
  49088. /**
  49089. * Returns true if the mesh should render, otherwise false.
  49090. * @param mesh The mesh to render
  49091. * @returns true if it should render otherwise false
  49092. */
  49093. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49094. /**
  49095. * Sets the required values for both the emissive texture and and the main color.
  49096. */
  49097. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49098. /**
  49099. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49100. * @param mesh The mesh to exclude from the highlight layer
  49101. */
  49102. addExcludedMesh(mesh: Mesh): void;
  49103. /**
  49104. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49105. * @param mesh The mesh to highlight
  49106. */
  49107. removeExcludedMesh(mesh: Mesh): void;
  49108. /**
  49109. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49110. * @param mesh mesh to test
  49111. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49112. */
  49113. hasMesh(mesh: AbstractMesh): boolean;
  49114. /**
  49115. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49116. * @param mesh The mesh to highlight
  49117. * @param color The color of the highlight
  49118. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49119. */
  49120. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49121. /**
  49122. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49123. * @param mesh The mesh to highlight
  49124. */
  49125. removeMesh(mesh: Mesh): void;
  49126. /**
  49127. * Force the stencil to the normal expected value for none glowing parts
  49128. */
  49129. private _defaultStencilReference;
  49130. /**
  49131. * Free any resources and references associated to a mesh.
  49132. * Internal use
  49133. * @param mesh The mesh to free.
  49134. * @hidden
  49135. */
  49136. _disposeMesh(mesh: Mesh): void;
  49137. /**
  49138. * Dispose the highlight layer and free resources.
  49139. */
  49140. dispose(): void;
  49141. /**
  49142. * Gets the class name of the effect layer
  49143. * @returns the string with the class name of the effect layer
  49144. */
  49145. getClassName(): string;
  49146. /**
  49147. * Serializes this Highlight layer
  49148. * @returns a serialized Highlight layer object
  49149. */
  49150. serialize(): any;
  49151. /**
  49152. * Creates a Highlight layer from parsed Highlight layer data
  49153. * @param parsedHightlightLayer defines the Highlight layer data
  49154. * @param scene defines the current scene
  49155. * @param rootUrl defines the root URL containing the Highlight layer information
  49156. * @returns a parsed Highlight layer
  49157. */
  49158. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49159. }
  49160. }
  49161. declare module "babylonjs/Layers/index" {
  49162. export * from "babylonjs/Layers/effectLayer";
  49163. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49164. export * from "babylonjs/Layers/glowLayer";
  49165. export * from "babylonjs/Layers/highlightLayer";
  49166. export * from "babylonjs/Layers/layer";
  49167. export * from "babylonjs/Layers/layerSceneComponent";
  49168. }
  49169. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49170. /** @hidden */
  49171. export var lensFlarePixelShader: {
  49172. name: string;
  49173. shader: string;
  49174. };
  49175. }
  49176. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49177. /** @hidden */
  49178. export var lensFlareVertexShader: {
  49179. name: string;
  49180. shader: string;
  49181. };
  49182. }
  49183. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49184. import { Scene } from "babylonjs/scene";
  49185. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49187. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49188. import "babylonjs/Shaders/lensFlare.fragment";
  49189. import "babylonjs/Shaders/lensFlare.vertex";
  49190. /**
  49191. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49192. * It is usually composed of several `lensFlare`.
  49193. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49194. */
  49195. export class LensFlareSystem {
  49196. /**
  49197. * Define the name of the lens flare system
  49198. */
  49199. name: string;
  49200. /**
  49201. * List of lens flares used in this system.
  49202. */
  49203. lensFlares: LensFlare[];
  49204. /**
  49205. * Define a limit from the border the lens flare can be visible.
  49206. */
  49207. borderLimit: number;
  49208. /**
  49209. * Define a viewport border we do not want to see the lens flare in.
  49210. */
  49211. viewportBorder: number;
  49212. /**
  49213. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49214. */
  49215. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49216. /**
  49217. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49218. */
  49219. layerMask: number;
  49220. /**
  49221. * Define the id of the lens flare system in the scene.
  49222. * (equal to name by default)
  49223. */
  49224. id: string;
  49225. private _scene;
  49226. private _emitter;
  49227. private _vertexBuffers;
  49228. private _indexBuffer;
  49229. private _effect;
  49230. private _positionX;
  49231. private _positionY;
  49232. private _isEnabled;
  49233. /** @hidden */
  49234. static _SceneComponentInitialization: (scene: Scene) => void;
  49235. /**
  49236. * Instantiates a lens flare system.
  49237. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49238. * It is usually composed of several `lensFlare`.
  49239. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49240. * @param name Define the name of the lens flare system in the scene
  49241. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49242. * @param scene Define the scene the lens flare system belongs to
  49243. */
  49244. constructor(
  49245. /**
  49246. * Define the name of the lens flare system
  49247. */
  49248. name: string, emitter: any, scene: Scene);
  49249. /**
  49250. * Define if the lens flare system is enabled.
  49251. */
  49252. isEnabled: boolean;
  49253. /**
  49254. * Get the scene the effects belongs to.
  49255. * @returns the scene holding the lens flare system
  49256. */
  49257. getScene(): Scene;
  49258. /**
  49259. * Get the emitter of the lens flare system.
  49260. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49261. * @returns the emitter of the lens flare system
  49262. */
  49263. getEmitter(): any;
  49264. /**
  49265. * Set the emitter of the lens flare system.
  49266. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49267. * @param newEmitter Define the new emitter of the system
  49268. */
  49269. setEmitter(newEmitter: any): void;
  49270. /**
  49271. * Get the lens flare system emitter position.
  49272. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49273. * @returns the position
  49274. */
  49275. getEmitterPosition(): Vector3;
  49276. /**
  49277. * @hidden
  49278. */
  49279. computeEffectivePosition(globalViewport: Viewport): boolean;
  49280. /** @hidden */
  49281. _isVisible(): boolean;
  49282. /**
  49283. * @hidden
  49284. */
  49285. render(): boolean;
  49286. /**
  49287. * Dispose and release the lens flare with its associated resources.
  49288. */
  49289. dispose(): void;
  49290. /**
  49291. * Parse a lens flare system from a JSON repressentation
  49292. * @param parsedLensFlareSystem Define the JSON to parse
  49293. * @param scene Define the scene the parsed system should be instantiated in
  49294. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49295. * @returns the parsed system
  49296. */
  49297. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49298. /**
  49299. * Serialize the current Lens Flare System into a JSON representation.
  49300. * @returns the serialized JSON
  49301. */
  49302. serialize(): any;
  49303. }
  49304. }
  49305. declare module "babylonjs/LensFlares/lensFlare" {
  49306. import { Nullable } from "babylonjs/types";
  49307. import { Color3 } from "babylonjs/Maths/math";
  49308. import { Texture } from "babylonjs/Materials/Textures/texture";
  49309. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49310. /**
  49311. * This represents one of the lens effect in a `lensFlareSystem`.
  49312. * It controls one of the indiviual texture used in the effect.
  49313. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49314. */
  49315. export class LensFlare {
  49316. /**
  49317. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49318. */
  49319. size: number;
  49320. /**
  49321. * 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.
  49322. */
  49323. position: number;
  49324. /**
  49325. * Define the lens color.
  49326. */
  49327. color: Color3;
  49328. /**
  49329. * Define the lens texture.
  49330. */
  49331. texture: Nullable<Texture>;
  49332. /**
  49333. * Define the alpha mode to render this particular lens.
  49334. */
  49335. alphaMode: number;
  49336. private _system;
  49337. /**
  49338. * Creates a new Lens Flare.
  49339. * This represents one of the lens effect in a `lensFlareSystem`.
  49340. * It controls one of the indiviual texture used in the effect.
  49341. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49342. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49343. * @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.
  49344. * @param color Define the lens color
  49345. * @param imgUrl Define the lens texture url
  49346. * @param system Define the `lensFlareSystem` this flare is part of
  49347. * @returns The newly created Lens Flare
  49348. */
  49349. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49350. /**
  49351. * Instantiates a new Lens Flare.
  49352. * This represents one of the lens effect in a `lensFlareSystem`.
  49353. * It controls one of the indiviual texture used in the effect.
  49354. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49355. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49356. * @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.
  49357. * @param color Define the lens color
  49358. * @param imgUrl Define the lens texture url
  49359. * @param system Define the `lensFlareSystem` this flare is part of
  49360. */
  49361. constructor(
  49362. /**
  49363. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49364. */
  49365. size: number,
  49366. /**
  49367. * 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.
  49368. */
  49369. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49370. /**
  49371. * Dispose and release the lens flare with its associated resources.
  49372. */
  49373. dispose(): void;
  49374. }
  49375. }
  49376. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49377. import { Nullable } from "babylonjs/types";
  49378. import { Scene } from "babylonjs/scene";
  49379. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49380. import { AbstractScene } from "babylonjs/abstractScene";
  49381. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49382. module "babylonjs/abstractScene" {
  49383. interface AbstractScene {
  49384. /**
  49385. * The list of lens flare system added to the scene
  49386. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49387. */
  49388. lensFlareSystems: Array<LensFlareSystem>;
  49389. /**
  49390. * Removes the given lens flare system from this scene.
  49391. * @param toRemove The lens flare system to remove
  49392. * @returns The index of the removed lens flare system
  49393. */
  49394. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49395. /**
  49396. * Adds the given lens flare system to this scene
  49397. * @param newLensFlareSystem The lens flare system to add
  49398. */
  49399. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49400. /**
  49401. * Gets a lens flare system using its name
  49402. * @param name defines the name to look for
  49403. * @returns the lens flare system or null if not found
  49404. */
  49405. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49406. /**
  49407. * Gets a lens flare system using its id
  49408. * @param id defines the id to look for
  49409. * @returns the lens flare system or null if not found
  49410. */
  49411. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49412. }
  49413. }
  49414. /**
  49415. * Defines the lens flare scene component responsible to manage any lens flares
  49416. * in a given scene.
  49417. */
  49418. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49419. /**
  49420. * The component name helpfull to identify the component in the list of scene components.
  49421. */
  49422. readonly name: string;
  49423. /**
  49424. * The scene the component belongs to.
  49425. */
  49426. scene: Scene;
  49427. /**
  49428. * Creates a new instance of the component for the given scene
  49429. * @param scene Defines the scene to register the component in
  49430. */
  49431. constructor(scene: Scene);
  49432. /**
  49433. * Registers the component in a given scene
  49434. */
  49435. register(): void;
  49436. /**
  49437. * Rebuilds the elements related to this component in case of
  49438. * context lost for instance.
  49439. */
  49440. rebuild(): void;
  49441. /**
  49442. * Adds all the element from the container to the scene
  49443. * @param container the container holding the elements
  49444. */
  49445. addFromContainer(container: AbstractScene): void;
  49446. /**
  49447. * Removes all the elements in the container from the scene
  49448. * @param container contains the elements to remove
  49449. * @param dispose if the removed element should be disposed (default: false)
  49450. */
  49451. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49452. /**
  49453. * Serializes the component data to the specified json object
  49454. * @param serializationObject The object to serialize to
  49455. */
  49456. serialize(serializationObject: any): void;
  49457. /**
  49458. * Disposes the component and the associated ressources.
  49459. */
  49460. dispose(): void;
  49461. private _draw;
  49462. }
  49463. }
  49464. declare module "babylonjs/LensFlares/index" {
  49465. export * from "babylonjs/LensFlares/lensFlare";
  49466. export * from "babylonjs/LensFlares/lensFlareSystem";
  49467. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49468. }
  49469. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49470. import { Scene } from "babylonjs/scene";
  49471. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49472. import { AbstractScene } from "babylonjs/abstractScene";
  49473. /**
  49474. * Defines the shadow generator component responsible to manage any shadow generators
  49475. * in a given scene.
  49476. */
  49477. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49478. /**
  49479. * The component name helpfull to identify the component in the list of scene components.
  49480. */
  49481. readonly name: string;
  49482. /**
  49483. * The scene the component belongs to.
  49484. */
  49485. scene: Scene;
  49486. /**
  49487. * Creates a new instance of the component for the given scene
  49488. * @param scene Defines the scene to register the component in
  49489. */
  49490. constructor(scene: Scene);
  49491. /**
  49492. * Registers the component in a given scene
  49493. */
  49494. register(): void;
  49495. /**
  49496. * Rebuilds the elements related to this component in case of
  49497. * context lost for instance.
  49498. */
  49499. rebuild(): void;
  49500. /**
  49501. * Serializes the component data to the specified json object
  49502. * @param serializationObject The object to serialize to
  49503. */
  49504. serialize(serializationObject: any): void;
  49505. /**
  49506. * Adds all the element from the container to the scene
  49507. * @param container the container holding the elements
  49508. */
  49509. addFromContainer(container: AbstractScene): void;
  49510. /**
  49511. * Removes all the elements in the container from the scene
  49512. * @param container contains the elements to remove
  49513. * @param dispose if the removed element should be disposed (default: false)
  49514. */
  49515. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49516. /**
  49517. * Rebuilds the elements related to this component in case of
  49518. * context lost for instance.
  49519. */
  49520. dispose(): void;
  49521. private _gatherRenderTargets;
  49522. }
  49523. }
  49524. declare module "babylonjs/Lights/Shadows/index" {
  49525. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49526. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49527. }
  49528. declare module "babylonjs/Lights/pointLight" {
  49529. import { Scene } from "babylonjs/scene";
  49530. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49531. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49532. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49533. import { Effect } from "babylonjs/Materials/effect";
  49534. /**
  49535. * A point light is a light defined by an unique point in world space.
  49536. * The light is emitted in every direction from this point.
  49537. * A good example of a point light is a standard light bulb.
  49538. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49539. */
  49540. export class PointLight extends ShadowLight {
  49541. private _shadowAngle;
  49542. /**
  49543. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49544. * This specifies what angle the shadow will use to be created.
  49545. *
  49546. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49547. */
  49548. /**
  49549. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49550. * This specifies what angle the shadow will use to be created.
  49551. *
  49552. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49553. */
  49554. shadowAngle: number;
  49555. /**
  49556. * Gets the direction if it has been set.
  49557. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49558. */
  49559. /**
  49560. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49561. */
  49562. direction: Vector3;
  49563. /**
  49564. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49565. * A PointLight emits the light in every direction.
  49566. * It can cast shadows.
  49567. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49568. * ```javascript
  49569. * var pointLight = new PointLight("pl", camera.position, scene);
  49570. * ```
  49571. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49572. * @param name The light friendly name
  49573. * @param position The position of the point light in the scene
  49574. * @param scene The scene the lights belongs to
  49575. */
  49576. constructor(name: string, position: Vector3, scene: Scene);
  49577. /**
  49578. * Returns the string "PointLight"
  49579. * @returns the class name
  49580. */
  49581. getClassName(): string;
  49582. /**
  49583. * Returns the integer 0.
  49584. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49585. */
  49586. getTypeID(): number;
  49587. /**
  49588. * Specifies wether or not the shadowmap should be a cube texture.
  49589. * @returns true if the shadowmap needs to be a cube texture.
  49590. */
  49591. needCube(): boolean;
  49592. /**
  49593. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49594. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49595. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49596. */
  49597. getShadowDirection(faceIndex?: number): Vector3;
  49598. /**
  49599. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49600. * - fov = PI / 2
  49601. * - aspect ratio : 1.0
  49602. * - z-near and far equal to the active camera minZ and maxZ.
  49603. * Returns the PointLight.
  49604. */
  49605. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49606. protected _buildUniformLayout(): void;
  49607. /**
  49608. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49609. * @param effect The effect to update
  49610. * @param lightIndex The index of the light in the effect to update
  49611. * @returns The point light
  49612. */
  49613. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49614. /**
  49615. * Prepares the list of defines specific to the light type.
  49616. * @param defines the list of defines
  49617. * @param lightIndex defines the index of the light for the effect
  49618. */
  49619. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49620. }
  49621. }
  49622. declare module "babylonjs/Lights/index" {
  49623. export * from "babylonjs/Lights/light";
  49624. export * from "babylonjs/Lights/shadowLight";
  49625. export * from "babylonjs/Lights/Shadows/index";
  49626. export * from "babylonjs/Lights/directionalLight";
  49627. export * from "babylonjs/Lights/hemisphericLight";
  49628. export * from "babylonjs/Lights/pointLight";
  49629. export * from "babylonjs/Lights/spotLight";
  49630. }
  49631. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49632. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49633. /**
  49634. * Header information of HDR texture files.
  49635. */
  49636. export interface HDRInfo {
  49637. /**
  49638. * The height of the texture in pixels.
  49639. */
  49640. height: number;
  49641. /**
  49642. * The width of the texture in pixels.
  49643. */
  49644. width: number;
  49645. /**
  49646. * The index of the beginning of the data in the binary file.
  49647. */
  49648. dataPosition: number;
  49649. }
  49650. /**
  49651. * This groups tools to convert HDR texture to native colors array.
  49652. */
  49653. export class HDRTools {
  49654. private static Ldexp;
  49655. private static Rgbe2float;
  49656. private static readStringLine;
  49657. /**
  49658. * Reads header information from an RGBE texture stored in a native array.
  49659. * More information on this format are available here:
  49660. * https://en.wikipedia.org/wiki/RGBE_image_format
  49661. *
  49662. * @param uint8array The binary file stored in native array.
  49663. * @return The header information.
  49664. */
  49665. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49666. /**
  49667. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49668. * This RGBE texture needs to store the information as a panorama.
  49669. *
  49670. * More information on this format are available here:
  49671. * https://en.wikipedia.org/wiki/RGBE_image_format
  49672. *
  49673. * @param buffer The binary file stored in an array buffer.
  49674. * @param size The expected size of the extracted cubemap.
  49675. * @return The Cube Map information.
  49676. */
  49677. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49678. /**
  49679. * Returns the pixels data extracted from an RGBE texture.
  49680. * This pixels will be stored left to right up to down in the R G B order in one array.
  49681. *
  49682. * More information on this format are available here:
  49683. * https://en.wikipedia.org/wiki/RGBE_image_format
  49684. *
  49685. * @param uint8array The binary file stored in an array buffer.
  49686. * @param hdrInfo The header information of the file.
  49687. * @return The pixels data in RGB right to left up to down order.
  49688. */
  49689. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49690. private static RGBE_ReadPixels_RLE;
  49691. }
  49692. }
  49693. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49694. import { Nullable } from "babylonjs/types";
  49695. import { Scene } from "babylonjs/scene";
  49696. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49697. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49698. /**
  49699. * This represents a texture coming from an HDR input.
  49700. *
  49701. * The only supported format is currently panorama picture stored in RGBE format.
  49702. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49703. */
  49704. export class HDRCubeTexture extends BaseTexture {
  49705. private static _facesMapping;
  49706. private _generateHarmonics;
  49707. private _noMipmap;
  49708. private _textureMatrix;
  49709. private _size;
  49710. private _onLoad;
  49711. private _onError;
  49712. /**
  49713. * The texture URL.
  49714. */
  49715. url: string;
  49716. /**
  49717. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49718. */
  49719. coordinatesMode: number;
  49720. protected _isBlocking: boolean;
  49721. /**
  49722. * Sets wether or not the texture is blocking during loading.
  49723. */
  49724. /**
  49725. * Gets wether or not the texture is blocking during loading.
  49726. */
  49727. isBlocking: boolean;
  49728. protected _rotationY: number;
  49729. /**
  49730. * Sets texture matrix rotation angle around Y axis in radians.
  49731. */
  49732. /**
  49733. * Gets texture matrix rotation angle around Y axis radians.
  49734. */
  49735. rotationY: number;
  49736. /**
  49737. * Gets or sets the center of the bounding box associated with the cube texture
  49738. * It must define where the camera used to render the texture was set
  49739. */
  49740. boundingBoxPosition: Vector3;
  49741. private _boundingBoxSize;
  49742. /**
  49743. * Gets or sets the size of the bounding box associated with the cube texture
  49744. * When defined, the cubemap will switch to local mode
  49745. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49746. * @example https://www.babylonjs-playground.com/#RNASML
  49747. */
  49748. boundingBoxSize: Vector3;
  49749. /**
  49750. * Instantiates an HDRTexture from the following parameters.
  49751. *
  49752. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49753. * @param scene The scene the texture will be used in
  49754. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49755. * @param noMipmap Forces to not generate the mipmap if true
  49756. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49757. * @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)
  49758. * @param reserved Reserved flag for internal use.
  49759. */
  49760. 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>);
  49761. /**
  49762. * Get the current class name of the texture useful for serialization or dynamic coding.
  49763. * @returns "HDRCubeTexture"
  49764. */
  49765. getClassName(): string;
  49766. /**
  49767. * Occurs when the file is raw .hdr file.
  49768. */
  49769. private loadTexture;
  49770. clone(): HDRCubeTexture;
  49771. delayLoad(): void;
  49772. /**
  49773. * Get the texture reflection matrix used to rotate/transform the reflection.
  49774. * @returns the reflection matrix
  49775. */
  49776. getReflectionTextureMatrix(): Matrix;
  49777. /**
  49778. * Set the texture reflection matrix used to rotate/transform the reflection.
  49779. * @param value Define the reflection matrix to set
  49780. */
  49781. setReflectionTextureMatrix(value: Matrix): void;
  49782. /**
  49783. * Parses a JSON representation of an HDR Texture in order to create the texture
  49784. * @param parsedTexture Define the JSON representation
  49785. * @param scene Define the scene the texture should be created in
  49786. * @param rootUrl Define the root url in case we need to load relative dependencies
  49787. * @returns the newly created texture after parsing
  49788. */
  49789. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49790. serialize(): any;
  49791. }
  49792. }
  49793. declare module "babylonjs/Physics/physicsEngine" {
  49794. import { Nullable } from "babylonjs/types";
  49795. import { Vector3 } from "babylonjs/Maths/math";
  49796. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49797. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49798. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49799. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49800. /**
  49801. * Class used to control physics engine
  49802. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49803. */
  49804. export class PhysicsEngine implements IPhysicsEngine {
  49805. private _physicsPlugin;
  49806. /**
  49807. * Global value used to control the smallest number supported by the simulation
  49808. */
  49809. static Epsilon: number;
  49810. private _impostors;
  49811. private _joints;
  49812. /**
  49813. * Gets the gravity vector used by the simulation
  49814. */
  49815. gravity: Vector3;
  49816. /**
  49817. * Factory used to create the default physics plugin.
  49818. * @returns The default physics plugin
  49819. */
  49820. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49821. /**
  49822. * Creates a new Physics Engine
  49823. * @param gravity defines the gravity vector used by the simulation
  49824. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49825. */
  49826. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49827. /**
  49828. * Sets the gravity vector used by the simulation
  49829. * @param gravity defines the gravity vector to use
  49830. */
  49831. setGravity(gravity: Vector3): void;
  49832. /**
  49833. * Set the time step of the physics engine.
  49834. * Default is 1/60.
  49835. * To slow it down, enter 1/600 for example.
  49836. * To speed it up, 1/30
  49837. * @param newTimeStep defines the new timestep to apply to this world.
  49838. */
  49839. setTimeStep(newTimeStep?: number): void;
  49840. /**
  49841. * Get the time step of the physics engine.
  49842. * @returns the current time step
  49843. */
  49844. getTimeStep(): number;
  49845. /**
  49846. * Release all resources
  49847. */
  49848. dispose(): void;
  49849. /**
  49850. * Gets the name of the current physics plugin
  49851. * @returns the name of the plugin
  49852. */
  49853. getPhysicsPluginName(): string;
  49854. /**
  49855. * Adding a new impostor for the impostor tracking.
  49856. * This will be done by the impostor itself.
  49857. * @param impostor the impostor to add
  49858. */
  49859. addImpostor(impostor: PhysicsImpostor): void;
  49860. /**
  49861. * Remove an impostor from the engine.
  49862. * This impostor and its mesh will not longer be updated by the physics engine.
  49863. * @param impostor the impostor to remove
  49864. */
  49865. removeImpostor(impostor: PhysicsImpostor): void;
  49866. /**
  49867. * Add a joint to the physics engine
  49868. * @param mainImpostor defines the main impostor to which the joint is added.
  49869. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49870. * @param joint defines the joint that will connect both impostors.
  49871. */
  49872. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49873. /**
  49874. * Removes a joint from the simulation
  49875. * @param mainImpostor defines the impostor used with the joint
  49876. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49877. * @param joint defines the joint to remove
  49878. */
  49879. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49880. /**
  49881. * Called by the scene. No need to call it.
  49882. * @param delta defines the timespam between frames
  49883. */
  49884. _step(delta: number): void;
  49885. /**
  49886. * Gets the current plugin used to run the simulation
  49887. * @returns current plugin
  49888. */
  49889. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49890. /**
  49891. * Gets the list of physic impostors
  49892. * @returns an array of PhysicsImpostor
  49893. */
  49894. getImpostors(): Array<PhysicsImpostor>;
  49895. /**
  49896. * Gets the impostor for a physics enabled object
  49897. * @param object defines the object impersonated by the impostor
  49898. * @returns the PhysicsImpostor or null if not found
  49899. */
  49900. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49901. /**
  49902. * Gets the impostor for a physics body object
  49903. * @param body defines physics body used by the impostor
  49904. * @returns the PhysicsImpostor or null if not found
  49905. */
  49906. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49907. /**
  49908. * Does a raycast in the physics world
  49909. * @param from when should the ray start?
  49910. * @param to when should the ray end?
  49911. * @returns PhysicsRaycastResult
  49912. */
  49913. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49914. }
  49915. }
  49916. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49917. import { Nullable } from "babylonjs/types";
  49918. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49919. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49920. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49921. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49922. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49923. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49924. /** @hidden */
  49925. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49926. private _useDeltaForWorldStep;
  49927. world: any;
  49928. name: string;
  49929. private _physicsMaterials;
  49930. private _fixedTimeStep;
  49931. private _cannonRaycastResult;
  49932. private _raycastResult;
  49933. private _removeAfterStep;
  49934. BJSCANNON: any;
  49935. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49936. setGravity(gravity: Vector3): void;
  49937. setTimeStep(timeStep: number): void;
  49938. getTimeStep(): number;
  49939. executeStep(delta: number): void;
  49940. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49941. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49942. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49943. private _processChildMeshes;
  49944. removePhysicsBody(impostor: PhysicsImpostor): void;
  49945. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49946. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49947. private _addMaterial;
  49948. private _checkWithEpsilon;
  49949. private _createShape;
  49950. private _createHeightmap;
  49951. private _minus90X;
  49952. private _plus90X;
  49953. private _tmpPosition;
  49954. private _tmpDeltaPosition;
  49955. private _tmpUnityRotation;
  49956. private _updatePhysicsBodyTransformation;
  49957. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49958. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49959. isSupported(): boolean;
  49960. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49961. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49962. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49963. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49964. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49965. getBodyMass(impostor: PhysicsImpostor): number;
  49966. getBodyFriction(impostor: PhysicsImpostor): number;
  49967. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49968. getBodyRestitution(impostor: PhysicsImpostor): number;
  49969. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49970. sleepBody(impostor: PhysicsImpostor): void;
  49971. wakeUpBody(impostor: PhysicsImpostor): void;
  49972. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49973. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49974. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49975. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49976. getRadius(impostor: PhysicsImpostor): number;
  49977. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49978. dispose(): void;
  49979. private _extendNamespace;
  49980. /**
  49981. * Does a raycast in the physics world
  49982. * @param from when should the ray start?
  49983. * @param to when should the ray end?
  49984. * @returns PhysicsRaycastResult
  49985. */
  49986. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49987. }
  49988. }
  49989. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  49990. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49991. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49992. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49994. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49995. import { Nullable } from "babylonjs/types";
  49996. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49997. /** @hidden */
  49998. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49999. world: any;
  50000. name: string;
  50001. BJSOIMO: any;
  50002. private _raycastResult;
  50003. constructor(iterations?: number, oimoInjection?: any);
  50004. setGravity(gravity: Vector3): void;
  50005. setTimeStep(timeStep: number): void;
  50006. getTimeStep(): number;
  50007. private _tmpImpostorsArray;
  50008. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50009. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50010. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50011. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50012. private _tmpPositionVector;
  50013. removePhysicsBody(impostor: PhysicsImpostor): void;
  50014. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50015. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50016. isSupported(): boolean;
  50017. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50018. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50019. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50020. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50021. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50022. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50023. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50024. getBodyMass(impostor: PhysicsImpostor): number;
  50025. getBodyFriction(impostor: PhysicsImpostor): number;
  50026. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50027. getBodyRestitution(impostor: PhysicsImpostor): number;
  50028. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50029. sleepBody(impostor: PhysicsImpostor): void;
  50030. wakeUpBody(impostor: PhysicsImpostor): void;
  50031. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50032. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50033. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50034. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50035. getRadius(impostor: PhysicsImpostor): number;
  50036. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50037. dispose(): void;
  50038. /**
  50039. * Does a raycast in the physics world
  50040. * @param from when should the ray start?
  50041. * @param to when should the ray end?
  50042. * @returns PhysicsRaycastResult
  50043. */
  50044. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50045. }
  50046. }
  50047. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50048. import { Nullable } from "babylonjs/types";
  50049. import { Scene } from "babylonjs/scene";
  50050. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50051. import { Mesh } from "babylonjs/Meshes/mesh";
  50052. /**
  50053. * Class containing static functions to help procedurally build meshes
  50054. */
  50055. export class RibbonBuilder {
  50056. /**
  50057. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50058. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50059. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50060. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50061. * * 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
  50062. * * 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
  50063. * * 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
  50064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50067. * * 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
  50068. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50069. * * 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
  50070. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50072. * @param name defines the name of the mesh
  50073. * @param options defines the options used to create the mesh
  50074. * @param scene defines the hosting scene
  50075. * @returns the ribbon mesh
  50076. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50077. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50078. */
  50079. static CreateRibbon(name: string, options: {
  50080. pathArray: Vector3[][];
  50081. closeArray?: boolean;
  50082. closePath?: boolean;
  50083. offset?: number;
  50084. updatable?: boolean;
  50085. sideOrientation?: number;
  50086. frontUVs?: Vector4;
  50087. backUVs?: Vector4;
  50088. instance?: Mesh;
  50089. invertUV?: boolean;
  50090. uvs?: Vector2[];
  50091. colors?: Color4[];
  50092. }, scene?: Nullable<Scene>): Mesh;
  50093. }
  50094. }
  50095. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50096. import { Nullable } from "babylonjs/types";
  50097. import { Scene } from "babylonjs/scene";
  50098. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50099. import { Mesh } from "babylonjs/Meshes/mesh";
  50100. /**
  50101. * Class containing static functions to help procedurally build meshes
  50102. */
  50103. export class ShapeBuilder {
  50104. /**
  50105. * 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.
  50106. * * 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.
  50107. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50108. * * 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.
  50109. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50110. * * 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
  50111. * * 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
  50112. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50113. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50114. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50115. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50117. * @param name defines the name of the mesh
  50118. * @param options defines the options used to create the mesh
  50119. * @param scene defines the hosting scene
  50120. * @returns the extruded shape mesh
  50121. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50123. */
  50124. static ExtrudeShape(name: string, options: {
  50125. shape: Vector3[];
  50126. path: Vector3[];
  50127. scale?: number;
  50128. rotation?: number;
  50129. cap?: number;
  50130. updatable?: boolean;
  50131. sideOrientation?: number;
  50132. frontUVs?: Vector4;
  50133. backUVs?: Vector4;
  50134. instance?: Mesh;
  50135. invertUV?: boolean;
  50136. }, scene?: Nullable<Scene>): Mesh;
  50137. /**
  50138. * Creates an custom extruded shape mesh.
  50139. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50140. * * 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.
  50141. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50142. * * 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
  50143. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50144. * * 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
  50145. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50146. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50147. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50148. * * 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
  50149. * * 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
  50150. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50153. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50155. * @param name defines the name of the mesh
  50156. * @param options defines the options used to create the mesh
  50157. * @param scene defines the hosting scene
  50158. * @returns the custom extruded shape mesh
  50159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50160. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50161. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50162. */
  50163. static ExtrudeShapeCustom(name: string, options: {
  50164. shape: Vector3[];
  50165. path: Vector3[];
  50166. scaleFunction?: any;
  50167. rotationFunction?: any;
  50168. ribbonCloseArray?: boolean;
  50169. ribbonClosePath?: boolean;
  50170. cap?: number;
  50171. updatable?: boolean;
  50172. sideOrientation?: number;
  50173. frontUVs?: Vector4;
  50174. backUVs?: Vector4;
  50175. instance?: Mesh;
  50176. invertUV?: boolean;
  50177. }, scene?: Nullable<Scene>): Mesh;
  50178. private static _ExtrudeShapeGeneric;
  50179. }
  50180. }
  50181. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50182. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50183. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50184. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50185. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50186. import { Nullable } from "babylonjs/types";
  50187. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50188. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50189. /**
  50190. * AmmoJS Physics plugin
  50191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50192. * @see https://github.com/kripken/ammo.js/
  50193. */
  50194. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50195. private _useDeltaForWorldStep;
  50196. /**
  50197. * Reference to the Ammo library
  50198. */
  50199. bjsAMMO: any;
  50200. /**
  50201. * Created ammoJS world which physics bodies are added to
  50202. */
  50203. world: any;
  50204. /**
  50205. * Name of the plugin
  50206. */
  50207. name: string;
  50208. private _timeStep;
  50209. private _fixedTimeStep;
  50210. private _maxSteps;
  50211. private _tmpQuaternion;
  50212. private _tmpAmmoTransform;
  50213. private _tmpAmmoQuaternion;
  50214. private _tmpAmmoConcreteContactResultCallback;
  50215. private _collisionConfiguration;
  50216. private _dispatcher;
  50217. private _overlappingPairCache;
  50218. private _solver;
  50219. private _softBodySolver;
  50220. private _tmpAmmoVectorA;
  50221. private _tmpAmmoVectorB;
  50222. private _tmpAmmoVectorC;
  50223. private _tmpAmmoVectorD;
  50224. private _tmpContactCallbackResult;
  50225. private _tmpAmmoVectorRCA;
  50226. private _tmpAmmoVectorRCB;
  50227. private _raycastResult;
  50228. private static readonly DISABLE_COLLISION_FLAG;
  50229. private static readonly KINEMATIC_FLAG;
  50230. private static readonly DISABLE_DEACTIVATION_FLAG;
  50231. /**
  50232. * Initializes the ammoJS plugin
  50233. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50234. * @param ammoInjection can be used to inject your own ammo reference
  50235. */
  50236. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50237. /**
  50238. * Sets the gravity of the physics world (m/(s^2))
  50239. * @param gravity Gravity to set
  50240. */
  50241. setGravity(gravity: Vector3): void;
  50242. /**
  50243. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50244. * @param timeStep timestep to use in seconds
  50245. */
  50246. setTimeStep(timeStep: number): void;
  50247. /**
  50248. * 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)
  50249. * @param fixedTimeStep fixedTimeStep to use in seconds
  50250. */
  50251. setFixedTimeStep(fixedTimeStep: number): void;
  50252. /**
  50253. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50254. * @param maxSteps the maximum number of steps by the physics engine per frame
  50255. */
  50256. setMaxSteps(maxSteps: number): void;
  50257. /**
  50258. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50259. * @returns the current timestep in seconds
  50260. */
  50261. getTimeStep(): number;
  50262. private _isImpostorInContact;
  50263. private _isImpostorPairInContact;
  50264. private _stepSimulation;
  50265. /**
  50266. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50267. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50268. * After the step the babylon meshes are set to the position of the physics imposters
  50269. * @param delta amount of time to step forward
  50270. * @param impostors array of imposters to update before/after the step
  50271. */
  50272. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50273. /**
  50274. * Update babylon mesh to match physics world object
  50275. * @param impostor imposter to match
  50276. */
  50277. private _afterSoftStep;
  50278. /**
  50279. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50280. * @param impostor imposter to match
  50281. */
  50282. private _ropeStep;
  50283. /**
  50284. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50285. * @param impostor imposter to match
  50286. */
  50287. private _softbodyOrClothStep;
  50288. private _tmpVector;
  50289. private _tmpMatrix;
  50290. /**
  50291. * Applies an impulse on the imposter
  50292. * @param impostor imposter to apply impulse to
  50293. * @param force amount of force to be applied to the imposter
  50294. * @param contactPoint the location to apply the impulse on the imposter
  50295. */
  50296. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50297. /**
  50298. * Applies a force on the imposter
  50299. * @param impostor imposter to apply force
  50300. * @param force amount of force to be applied to the imposter
  50301. * @param contactPoint the location to apply the force on the imposter
  50302. */
  50303. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50304. /**
  50305. * Creates a physics body using the plugin
  50306. * @param impostor the imposter to create the physics body on
  50307. */
  50308. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50309. /**
  50310. * Removes the physics body from the imposter and disposes of the body's memory
  50311. * @param impostor imposter to remove the physics body from
  50312. */
  50313. removePhysicsBody(impostor: PhysicsImpostor): void;
  50314. /**
  50315. * Generates a joint
  50316. * @param impostorJoint the imposter joint to create the joint with
  50317. */
  50318. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50319. /**
  50320. * Removes a joint
  50321. * @param impostorJoint the imposter joint to remove the joint from
  50322. */
  50323. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50324. private _addMeshVerts;
  50325. /**
  50326. * Initialise the soft body vertices to match its object's (mesh) vertices
  50327. * Softbody vertices (nodes) are in world space and to match this
  50328. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50329. * @param impostor to create the softbody for
  50330. */
  50331. private _softVertexData;
  50332. /**
  50333. * Create an impostor's soft body
  50334. * @param impostor to create the softbody for
  50335. */
  50336. private _createSoftbody;
  50337. /**
  50338. * Create cloth for an impostor
  50339. * @param impostor to create the softbody for
  50340. */
  50341. private _createCloth;
  50342. /**
  50343. * Create rope for an impostor
  50344. * @param impostor to create the softbody for
  50345. */
  50346. private _createRope;
  50347. private _addHullVerts;
  50348. private _createShape;
  50349. /**
  50350. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50351. * @param impostor imposter containing the physics body and babylon object
  50352. */
  50353. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50354. /**
  50355. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50356. * @param impostor imposter containing the physics body and babylon object
  50357. * @param newPosition new position
  50358. * @param newRotation new rotation
  50359. */
  50360. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50361. /**
  50362. * If this plugin is supported
  50363. * @returns true if its supported
  50364. */
  50365. isSupported(): boolean;
  50366. /**
  50367. * Sets the linear velocity of the physics body
  50368. * @param impostor imposter to set the velocity on
  50369. * @param velocity velocity to set
  50370. */
  50371. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50372. /**
  50373. * Sets the angular velocity of the physics body
  50374. * @param impostor imposter to set the velocity on
  50375. * @param velocity velocity to set
  50376. */
  50377. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50378. /**
  50379. * gets the linear velocity
  50380. * @param impostor imposter to get linear velocity from
  50381. * @returns linear velocity
  50382. */
  50383. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50384. /**
  50385. * gets the angular velocity
  50386. * @param impostor imposter to get angular velocity from
  50387. * @returns angular velocity
  50388. */
  50389. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50390. /**
  50391. * Sets the mass of physics body
  50392. * @param impostor imposter to set the mass on
  50393. * @param mass mass to set
  50394. */
  50395. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50396. /**
  50397. * Gets the mass of the physics body
  50398. * @param impostor imposter to get the mass from
  50399. * @returns mass
  50400. */
  50401. getBodyMass(impostor: PhysicsImpostor): number;
  50402. /**
  50403. * Gets friction of the impostor
  50404. * @param impostor impostor to get friction from
  50405. * @returns friction value
  50406. */
  50407. getBodyFriction(impostor: PhysicsImpostor): number;
  50408. /**
  50409. * Sets friction of the impostor
  50410. * @param impostor impostor to set friction on
  50411. * @param friction friction value
  50412. */
  50413. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50414. /**
  50415. * Gets restitution of the impostor
  50416. * @param impostor impostor to get restitution from
  50417. * @returns restitution value
  50418. */
  50419. getBodyRestitution(impostor: PhysicsImpostor): number;
  50420. /**
  50421. * Sets resitution of the impostor
  50422. * @param impostor impostor to set resitution on
  50423. * @param restitution resitution value
  50424. */
  50425. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50426. /**
  50427. * Gets pressure inside the impostor
  50428. * @param impostor impostor to get pressure from
  50429. * @returns pressure value
  50430. */
  50431. getBodyPressure(impostor: PhysicsImpostor): number;
  50432. /**
  50433. * Sets pressure inside a soft body impostor
  50434. * Cloth and rope must remain 0 pressure
  50435. * @param impostor impostor to set pressure on
  50436. * @param pressure pressure value
  50437. */
  50438. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50439. /**
  50440. * Gets stiffness of the impostor
  50441. * @param impostor impostor to get stiffness from
  50442. * @returns pressure value
  50443. */
  50444. getBodyStiffness(impostor: PhysicsImpostor): number;
  50445. /**
  50446. * Sets stiffness of the impostor
  50447. * @param impostor impostor to set stiffness on
  50448. * @param stiffness stiffness value from 0 to 1
  50449. */
  50450. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50451. /**
  50452. * Gets velocityIterations of the impostor
  50453. * @param impostor impostor to get velocity iterations from
  50454. * @returns velocityIterations value
  50455. */
  50456. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50457. /**
  50458. * Sets velocityIterations of the impostor
  50459. * @param impostor impostor to set velocity iterations on
  50460. * @param velocityIterations velocityIterations value
  50461. */
  50462. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50463. /**
  50464. * Gets positionIterations of the impostor
  50465. * @param impostor impostor to get position iterations from
  50466. * @returns positionIterations value
  50467. */
  50468. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50469. /**
  50470. * Sets positionIterations of the impostor
  50471. * @param impostor impostor to set position on
  50472. * @param positionIterations positionIterations value
  50473. */
  50474. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50475. /**
  50476. * Append an anchor to a cloth object
  50477. * @param impostor is the cloth impostor to add anchor to
  50478. * @param otherImpostor is the rigid impostor to anchor to
  50479. * @param width ratio across width from 0 to 1
  50480. * @param height ratio up height from 0 to 1
  50481. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50482. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50483. */
  50484. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50485. /**
  50486. * Append an hook to a rope object
  50487. * @param impostor is the rope impostor to add hook to
  50488. * @param otherImpostor is the rigid impostor to hook to
  50489. * @param length ratio along the rope from 0 to 1
  50490. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50491. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50492. */
  50493. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50494. /**
  50495. * Sleeps the physics body and stops it from being active
  50496. * @param impostor impostor to sleep
  50497. */
  50498. sleepBody(impostor: PhysicsImpostor): void;
  50499. /**
  50500. * Activates the physics body
  50501. * @param impostor impostor to activate
  50502. */
  50503. wakeUpBody(impostor: PhysicsImpostor): void;
  50504. /**
  50505. * Updates the distance parameters of the joint
  50506. * @param joint joint to update
  50507. * @param maxDistance maximum distance of the joint
  50508. * @param minDistance minimum distance of the joint
  50509. */
  50510. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50511. /**
  50512. * Sets a motor on the joint
  50513. * @param joint joint to set motor on
  50514. * @param speed speed of the motor
  50515. * @param maxForce maximum force of the motor
  50516. * @param motorIndex index of the motor
  50517. */
  50518. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50519. /**
  50520. * Sets the motors limit
  50521. * @param joint joint to set limit on
  50522. * @param upperLimit upper limit
  50523. * @param lowerLimit lower limit
  50524. */
  50525. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50526. /**
  50527. * Syncs the position and rotation of a mesh with the impostor
  50528. * @param mesh mesh to sync
  50529. * @param impostor impostor to update the mesh with
  50530. */
  50531. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50532. /**
  50533. * Gets the radius of the impostor
  50534. * @param impostor impostor to get radius from
  50535. * @returns the radius
  50536. */
  50537. getRadius(impostor: PhysicsImpostor): number;
  50538. /**
  50539. * Gets the box size of the impostor
  50540. * @param impostor impostor to get box size from
  50541. * @param result the resulting box size
  50542. */
  50543. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50544. /**
  50545. * Disposes of the impostor
  50546. */
  50547. dispose(): void;
  50548. /**
  50549. * Does a raycast in the physics world
  50550. * @param from when should the ray start?
  50551. * @param to when should the ray end?
  50552. * @returns PhysicsRaycastResult
  50553. */
  50554. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50555. }
  50556. }
  50557. declare module "babylonjs/Probes/reflectionProbe" {
  50558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50559. import { Vector3 } from "babylonjs/Maths/math";
  50560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50561. import { Nullable } from "babylonjs/types";
  50562. import { Scene } from "babylonjs/scene";
  50563. module "babylonjs/abstractScene" {
  50564. interface AbstractScene {
  50565. /**
  50566. * The list of reflection probes added to the scene
  50567. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50568. */
  50569. reflectionProbes: Array<ReflectionProbe>;
  50570. /**
  50571. * Removes the given reflection probe from this scene.
  50572. * @param toRemove The reflection probe to remove
  50573. * @returns The index of the removed reflection probe
  50574. */
  50575. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50576. /**
  50577. * Adds the given reflection probe to this scene.
  50578. * @param newReflectionProbe The reflection probe to add
  50579. */
  50580. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50581. }
  50582. }
  50583. /**
  50584. * Class used to generate realtime reflection / refraction cube textures
  50585. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50586. */
  50587. export class ReflectionProbe {
  50588. /** defines the name of the probe */
  50589. name: string;
  50590. private _scene;
  50591. private _renderTargetTexture;
  50592. private _projectionMatrix;
  50593. private _viewMatrix;
  50594. private _target;
  50595. private _add;
  50596. private _attachedMesh;
  50597. private _invertYAxis;
  50598. /** Gets or sets probe position (center of the cube map) */
  50599. position: Vector3;
  50600. /**
  50601. * Creates a new reflection probe
  50602. * @param name defines the name of the probe
  50603. * @param size defines the texture resolution (for each face)
  50604. * @param scene defines the hosting scene
  50605. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50606. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50607. */
  50608. constructor(
  50609. /** defines the name of the probe */
  50610. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50611. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50612. samples: number;
  50613. /** Gets or sets the refresh rate to use (on every frame by default) */
  50614. refreshRate: number;
  50615. /**
  50616. * Gets the hosting scene
  50617. * @returns a Scene
  50618. */
  50619. getScene(): Scene;
  50620. /** Gets the internal CubeTexture used to render to */
  50621. readonly cubeTexture: RenderTargetTexture;
  50622. /** Gets the list of meshes to render */
  50623. readonly renderList: Nullable<AbstractMesh[]>;
  50624. /**
  50625. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50626. * @param mesh defines the mesh to attach to
  50627. */
  50628. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50629. /**
  50630. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50631. * @param renderingGroupId The rendering group id corresponding to its index
  50632. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50633. */
  50634. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50635. /**
  50636. * Clean all associated resources
  50637. */
  50638. dispose(): void;
  50639. /**
  50640. * Converts the reflection probe information to a readable string for debug purpose.
  50641. * @param fullDetails Supports for multiple levels of logging within scene loading
  50642. * @returns the human readable reflection probe info
  50643. */
  50644. toString(fullDetails?: boolean): string;
  50645. /**
  50646. * Get the class name of the relfection probe.
  50647. * @returns "ReflectionProbe"
  50648. */
  50649. getClassName(): string;
  50650. /**
  50651. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50652. * @returns The JSON representation of the texture
  50653. */
  50654. serialize(): any;
  50655. /**
  50656. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50657. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50658. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50659. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50660. * @returns The parsed reflection probe if successful
  50661. */
  50662. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50663. }
  50664. }
  50665. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50666. /** @hidden */
  50667. export var _BabylonLoaderRegistered: boolean;
  50668. }
  50669. declare module "babylonjs/Loading/Plugins/index" {
  50670. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50671. }
  50672. declare module "babylonjs/Loading/index" {
  50673. export * from "babylonjs/Loading/loadingScreen";
  50674. export * from "babylonjs/Loading/Plugins/index";
  50675. export * from "babylonjs/Loading/sceneLoader";
  50676. export * from "babylonjs/Loading/sceneLoaderFlags";
  50677. }
  50678. declare module "babylonjs/Materials/Background/index" {
  50679. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50680. }
  50681. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50682. import { Scene } from "babylonjs/scene";
  50683. import { Color3 } from "babylonjs/Maths/math";
  50684. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50685. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50686. /**
  50687. * The Physically based simple base material of BJS.
  50688. *
  50689. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50690. * It is used as the base class for both the specGloss and metalRough conventions.
  50691. */
  50692. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50693. /**
  50694. * Number of Simultaneous lights allowed on the material.
  50695. */
  50696. maxSimultaneousLights: number;
  50697. /**
  50698. * If sets to true, disables all the lights affecting the material.
  50699. */
  50700. disableLighting: boolean;
  50701. /**
  50702. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50703. */
  50704. environmentTexture: BaseTexture;
  50705. /**
  50706. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50707. */
  50708. invertNormalMapX: boolean;
  50709. /**
  50710. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50711. */
  50712. invertNormalMapY: boolean;
  50713. /**
  50714. * Normal map used in the model.
  50715. */
  50716. normalTexture: BaseTexture;
  50717. /**
  50718. * Emissivie color used to self-illuminate the model.
  50719. */
  50720. emissiveColor: Color3;
  50721. /**
  50722. * Emissivie texture used to self-illuminate the model.
  50723. */
  50724. emissiveTexture: BaseTexture;
  50725. /**
  50726. * Occlusion Channel Strenght.
  50727. */
  50728. occlusionStrength: number;
  50729. /**
  50730. * Occlusion Texture of the material (adding extra occlusion effects).
  50731. */
  50732. occlusionTexture: BaseTexture;
  50733. /**
  50734. * Defines the alpha limits in alpha test mode.
  50735. */
  50736. alphaCutOff: number;
  50737. /**
  50738. * Gets the current double sided mode.
  50739. */
  50740. /**
  50741. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50742. */
  50743. doubleSided: boolean;
  50744. /**
  50745. * Stores the pre-calculated light information of a mesh in a texture.
  50746. */
  50747. lightmapTexture: BaseTexture;
  50748. /**
  50749. * If true, the light map contains occlusion information instead of lighting info.
  50750. */
  50751. useLightmapAsShadowmap: boolean;
  50752. /**
  50753. * Instantiates a new PBRMaterial instance.
  50754. *
  50755. * @param name The material name
  50756. * @param scene The scene the material will be use in.
  50757. */
  50758. constructor(name: string, scene: Scene);
  50759. getClassName(): string;
  50760. }
  50761. }
  50762. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50763. import { Scene } from "babylonjs/scene";
  50764. import { Color3 } from "babylonjs/Maths/math";
  50765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50766. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50767. /**
  50768. * The PBR material of BJS following the metal roughness convention.
  50769. *
  50770. * This fits to the PBR convention in the GLTF definition:
  50771. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50772. */
  50773. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50774. /**
  50775. * The base color has two different interpretations depending on the value of metalness.
  50776. * When the material is a metal, the base color is the specific measured reflectance value
  50777. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50778. * of the material.
  50779. */
  50780. baseColor: Color3;
  50781. /**
  50782. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50783. * well as opacity information in the alpha channel.
  50784. */
  50785. baseTexture: BaseTexture;
  50786. /**
  50787. * Specifies the metallic scalar value of the material.
  50788. * Can also be used to scale the metalness values of the metallic texture.
  50789. */
  50790. metallic: number;
  50791. /**
  50792. * Specifies the roughness scalar value of the material.
  50793. * Can also be used to scale the roughness values of the metallic texture.
  50794. */
  50795. roughness: number;
  50796. /**
  50797. * Texture containing both the metallic value in the B channel and the
  50798. * roughness value in the G channel to keep better precision.
  50799. */
  50800. metallicRoughnessTexture: BaseTexture;
  50801. /**
  50802. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50803. *
  50804. * @param name The material name
  50805. * @param scene The scene the material will be use in.
  50806. */
  50807. constructor(name: string, scene: Scene);
  50808. /**
  50809. * Return the currrent class name of the material.
  50810. */
  50811. getClassName(): string;
  50812. /**
  50813. * Makes a duplicate of the current material.
  50814. * @param name - name to use for the new material.
  50815. */
  50816. clone(name: string): PBRMetallicRoughnessMaterial;
  50817. /**
  50818. * Serialize the material to a parsable JSON object.
  50819. */
  50820. serialize(): any;
  50821. /**
  50822. * Parses a JSON object correponding to the serialize function.
  50823. */
  50824. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50825. }
  50826. }
  50827. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50828. import { Scene } from "babylonjs/scene";
  50829. import { Color3 } from "babylonjs/Maths/math";
  50830. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50831. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50832. /**
  50833. * The PBR material of BJS following the specular glossiness convention.
  50834. *
  50835. * This fits to the PBR convention in the GLTF definition:
  50836. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50837. */
  50838. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50839. /**
  50840. * Specifies the diffuse color of the material.
  50841. */
  50842. diffuseColor: Color3;
  50843. /**
  50844. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50845. * channel.
  50846. */
  50847. diffuseTexture: BaseTexture;
  50848. /**
  50849. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50850. */
  50851. specularColor: Color3;
  50852. /**
  50853. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50854. */
  50855. glossiness: number;
  50856. /**
  50857. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50858. */
  50859. specularGlossinessTexture: BaseTexture;
  50860. /**
  50861. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50862. *
  50863. * @param name The material name
  50864. * @param scene The scene the material will be use in.
  50865. */
  50866. constructor(name: string, scene: Scene);
  50867. /**
  50868. * Return the currrent class name of the material.
  50869. */
  50870. getClassName(): string;
  50871. /**
  50872. * Makes a duplicate of the current material.
  50873. * @param name - name to use for the new material.
  50874. */
  50875. clone(name: string): PBRSpecularGlossinessMaterial;
  50876. /**
  50877. * Serialize the material to a parsable JSON object.
  50878. */
  50879. serialize(): any;
  50880. /**
  50881. * Parses a JSON object correponding to the serialize function.
  50882. */
  50883. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50884. }
  50885. }
  50886. declare module "babylonjs/Materials/PBR/index" {
  50887. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50888. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50889. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50890. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50891. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50892. }
  50893. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50894. import { Nullable } from "babylonjs/types";
  50895. import { Scene } from "babylonjs/scene";
  50896. import { Matrix } from "babylonjs/Maths/math";
  50897. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50898. /**
  50899. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50900. * It can help converting any input color in a desired output one. This can then be used to create effects
  50901. * from sepia, black and white to sixties or futuristic rendering...
  50902. *
  50903. * The only supported format is currently 3dl.
  50904. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50905. */
  50906. export class ColorGradingTexture extends BaseTexture {
  50907. /**
  50908. * The current texture matrix. (will always be identity in color grading texture)
  50909. */
  50910. private _textureMatrix;
  50911. /**
  50912. * The texture URL.
  50913. */
  50914. url: string;
  50915. /**
  50916. * Empty line regex stored for GC.
  50917. */
  50918. private static _noneEmptyLineRegex;
  50919. private _engine;
  50920. /**
  50921. * Instantiates a ColorGradingTexture from the following parameters.
  50922. *
  50923. * @param url The location of the color gradind data (currently only supporting 3dl)
  50924. * @param scene The scene the texture will be used in
  50925. */
  50926. constructor(url: string, scene: Scene);
  50927. /**
  50928. * Returns the texture matrix used in most of the material.
  50929. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50930. */
  50931. getTextureMatrix(): Matrix;
  50932. /**
  50933. * Occurs when the file being loaded is a .3dl LUT file.
  50934. */
  50935. private load3dlTexture;
  50936. /**
  50937. * Starts the loading process of the texture.
  50938. */
  50939. private loadTexture;
  50940. /**
  50941. * Clones the color gradind texture.
  50942. */
  50943. clone(): ColorGradingTexture;
  50944. /**
  50945. * Called during delayed load for textures.
  50946. */
  50947. delayLoad(): void;
  50948. /**
  50949. * Parses a color grading texture serialized by Babylon.
  50950. * @param parsedTexture The texture information being parsedTexture
  50951. * @param scene The scene to load the texture in
  50952. * @param rootUrl The root url of the data assets to load
  50953. * @return A color gradind texture
  50954. */
  50955. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50956. /**
  50957. * Serializes the LUT texture to json format.
  50958. */
  50959. serialize(): any;
  50960. }
  50961. }
  50962. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  50963. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50964. import { Scene } from "babylonjs/scene";
  50965. import { Nullable } from "babylonjs/types";
  50966. /**
  50967. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50968. */
  50969. export class EquiRectangularCubeTexture extends BaseTexture {
  50970. /** The six faces of the cube. */
  50971. private static _FacesMapping;
  50972. private _noMipmap;
  50973. private _onLoad;
  50974. private _onError;
  50975. /** The size of the cubemap. */
  50976. private _size;
  50977. /** The buffer of the image. */
  50978. private _buffer;
  50979. /** The width of the input image. */
  50980. private _width;
  50981. /** The height of the input image. */
  50982. private _height;
  50983. /** The URL to the image. */
  50984. url: string;
  50985. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50986. coordinatesMode: number;
  50987. /**
  50988. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50989. * @param url The location of the image
  50990. * @param scene The scene the texture will be used in
  50991. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50992. * @param noMipmap Forces to not generate the mipmap if true
  50993. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50994. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50995. * @param onLoad — defines a callback called when texture is loaded
  50996. * @param onError — defines a callback called if there is an error
  50997. */
  50998. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50999. /**
  51000. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51001. */
  51002. private loadImage;
  51003. /**
  51004. * Convert the image buffer into a cubemap and create a CubeTexture.
  51005. */
  51006. private loadTexture;
  51007. /**
  51008. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51009. * @param buffer The ArrayBuffer that should be converted.
  51010. * @returns The buffer as Float32Array.
  51011. */
  51012. private getFloat32ArrayFromArrayBuffer;
  51013. /**
  51014. * Get the current class name of the texture useful for serialization or dynamic coding.
  51015. * @returns "EquiRectangularCubeTexture"
  51016. */
  51017. getClassName(): string;
  51018. /**
  51019. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51020. * @returns A clone of the current EquiRectangularCubeTexture.
  51021. */
  51022. clone(): EquiRectangularCubeTexture;
  51023. }
  51024. }
  51025. declare module "babylonjs/Misc/tga" {
  51026. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51027. /**
  51028. * Based on jsTGALoader - Javascript loader for TGA file
  51029. * By Vincent Thibault
  51030. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51031. */
  51032. export class TGATools {
  51033. private static _TYPE_INDEXED;
  51034. private static _TYPE_RGB;
  51035. private static _TYPE_GREY;
  51036. private static _TYPE_RLE_INDEXED;
  51037. private static _TYPE_RLE_RGB;
  51038. private static _TYPE_RLE_GREY;
  51039. private static _ORIGIN_MASK;
  51040. private static _ORIGIN_SHIFT;
  51041. private static _ORIGIN_BL;
  51042. private static _ORIGIN_BR;
  51043. private static _ORIGIN_UL;
  51044. private static _ORIGIN_UR;
  51045. /**
  51046. * Gets the header of a TGA file
  51047. * @param data defines the TGA data
  51048. * @returns the header
  51049. */
  51050. static GetTGAHeader(data: Uint8Array): any;
  51051. /**
  51052. * Uploads TGA content to a Babylon Texture
  51053. * @hidden
  51054. */
  51055. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51056. /** @hidden */
  51057. 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;
  51058. /** @hidden */
  51059. 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;
  51060. /** @hidden */
  51061. 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;
  51062. /** @hidden */
  51063. 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;
  51064. /** @hidden */
  51065. 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;
  51066. /** @hidden */
  51067. 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;
  51068. }
  51069. }
  51070. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51071. import { Nullable } from "babylonjs/types";
  51072. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51073. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51074. /**
  51075. * Implementation of the TGA Texture Loader.
  51076. * @hidden
  51077. */
  51078. export class _TGATextureLoader implements IInternalTextureLoader {
  51079. /**
  51080. * Defines wether the loader supports cascade loading the different faces.
  51081. */
  51082. readonly supportCascades: boolean;
  51083. /**
  51084. * This returns if the loader support the current file information.
  51085. * @param extension defines the file extension of the file being loaded
  51086. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51087. * @param fallback defines the fallback internal texture if any
  51088. * @param isBase64 defines whether the texture is encoded as a base64
  51089. * @param isBuffer defines whether the texture data are stored as a buffer
  51090. * @returns true if the loader can load the specified file
  51091. */
  51092. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51093. /**
  51094. * Transform the url before loading if required.
  51095. * @param rootUrl the url of the texture
  51096. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51097. * @returns the transformed texture
  51098. */
  51099. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51100. /**
  51101. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51102. * @param rootUrl the url of the texture
  51103. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51104. * @returns the fallback texture
  51105. */
  51106. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51107. /**
  51108. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51109. * @param data contains the texture data
  51110. * @param texture defines the BabylonJS internal texture
  51111. * @param createPolynomials will be true if polynomials have been requested
  51112. * @param onLoad defines the callback to trigger once the texture is ready
  51113. * @param onError defines the callback to trigger in case of error
  51114. */
  51115. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51116. /**
  51117. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51118. * @param data contains the texture data
  51119. * @param texture defines the BabylonJS internal texture
  51120. * @param callback defines the method to call once ready to upload
  51121. */
  51122. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51123. }
  51124. }
  51125. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51126. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51127. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51128. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51129. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51130. }
  51131. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51132. import { Scene } from "babylonjs/scene";
  51133. import { Texture } from "babylonjs/Materials/Textures/texture";
  51134. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51135. /**
  51136. * 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.
  51137. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51138. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51139. */
  51140. export class CustomProceduralTexture extends ProceduralTexture {
  51141. private _animate;
  51142. private _time;
  51143. private _config;
  51144. private _texturePath;
  51145. /**
  51146. * Instantiates a new Custom Procedural Texture.
  51147. * 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.
  51148. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51149. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51150. * @param name Define the name of the texture
  51151. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51152. * @param size Define the size of the texture to create
  51153. * @param scene Define the scene the texture belongs to
  51154. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51155. * @param generateMipMaps Define if the texture should creates mip maps or not
  51156. */
  51157. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51158. private _loadJson;
  51159. /**
  51160. * Is the texture ready to be used ? (rendered at least once)
  51161. * @returns true if ready, otherwise, false.
  51162. */
  51163. isReady(): boolean;
  51164. /**
  51165. * Render the texture to its associated render target.
  51166. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51167. */
  51168. render(useCameraPostProcess?: boolean): void;
  51169. /**
  51170. * Update the list of dependant textures samplers in the shader.
  51171. */
  51172. updateTextures(): void;
  51173. /**
  51174. * Update the uniform values of the procedural texture in the shader.
  51175. */
  51176. updateShaderUniforms(): void;
  51177. /**
  51178. * Define if the texture animates or not.
  51179. */
  51180. animate: boolean;
  51181. }
  51182. }
  51183. declare module "babylonjs/Shaders/noise.fragment" {
  51184. /** @hidden */
  51185. export var noisePixelShader: {
  51186. name: string;
  51187. shader: string;
  51188. };
  51189. }
  51190. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51191. import { Nullable } from "babylonjs/types";
  51192. import { Scene } from "babylonjs/scene";
  51193. import { Texture } from "babylonjs/Materials/Textures/texture";
  51194. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51195. import "babylonjs/Shaders/noise.fragment";
  51196. /**
  51197. * Class used to generate noise procedural textures
  51198. */
  51199. export class NoiseProceduralTexture extends ProceduralTexture {
  51200. private _time;
  51201. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51202. brightness: number;
  51203. /** Defines the number of octaves to process */
  51204. octaves: number;
  51205. /** Defines the level of persistence (0.8 by default) */
  51206. persistence: number;
  51207. /** Gets or sets animation speed factor (default is 1) */
  51208. animationSpeedFactor: number;
  51209. /**
  51210. * Creates a new NoiseProceduralTexture
  51211. * @param name defines the name fo the texture
  51212. * @param size defines the size of the texture (default is 256)
  51213. * @param scene defines the hosting scene
  51214. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51215. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51216. */
  51217. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51218. private _updateShaderUniforms;
  51219. protected _getDefines(): string;
  51220. /** Generate the current state of the procedural texture */
  51221. render(useCameraPostProcess?: boolean): void;
  51222. /**
  51223. * Serializes this noise procedural texture
  51224. * @returns a serialized noise procedural texture object
  51225. */
  51226. serialize(): any;
  51227. /**
  51228. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51229. * @param parsedTexture defines parsed texture data
  51230. * @param scene defines the current scene
  51231. * @param rootUrl defines the root URL containing noise procedural texture information
  51232. * @returns a parsed NoiseProceduralTexture
  51233. */
  51234. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51235. }
  51236. }
  51237. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51238. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51239. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51240. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51241. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51242. }
  51243. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51244. import { Nullable } from "babylonjs/types";
  51245. import { Scene } from "babylonjs/scene";
  51246. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51247. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51248. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51249. /**
  51250. * Raw cube texture where the raw buffers are passed in
  51251. */
  51252. export class RawCubeTexture extends CubeTexture {
  51253. /**
  51254. * Creates a cube texture where the raw buffers are passed in.
  51255. * @param scene defines the scene the texture is attached to
  51256. * @param data defines the array of data to use to create each face
  51257. * @param size defines the size of the textures
  51258. * @param format defines the format of the data
  51259. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51260. * @param generateMipMaps defines if the engine should generate the mip levels
  51261. * @param invertY defines if data must be stored with Y axis inverted
  51262. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51263. * @param compression defines the compression used (null by default)
  51264. */
  51265. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51266. /**
  51267. * Updates the raw cube texture.
  51268. * @param data defines the data to store
  51269. * @param format defines the data format
  51270. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51271. * @param invertY defines if data must be stored with Y axis inverted
  51272. * @param compression defines the compression used (null by default)
  51273. * @param level defines which level of the texture to update
  51274. */
  51275. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51276. /**
  51277. * Updates a raw cube texture with RGBD encoded data.
  51278. * @param data defines the array of data [mipmap][face] to use to create each face
  51279. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51280. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51281. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51282. * @returns a promsie that resolves when the operation is complete
  51283. */
  51284. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51285. /**
  51286. * Clones the raw cube texture.
  51287. * @return a new cube texture
  51288. */
  51289. clone(): CubeTexture;
  51290. /** @hidden */
  51291. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51292. }
  51293. }
  51294. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51295. import { Scene } from "babylonjs/scene";
  51296. import { Texture } from "babylonjs/Materials/Textures/texture";
  51297. /**
  51298. * Class used to store 3D textures containing user data
  51299. */
  51300. export class RawTexture3D extends Texture {
  51301. /** Gets or sets the texture format to use */
  51302. format: number;
  51303. private _engine;
  51304. /**
  51305. * Create a new RawTexture3D
  51306. * @param data defines the data of the texture
  51307. * @param width defines the width of the texture
  51308. * @param height defines the height of the texture
  51309. * @param depth defines the depth of the texture
  51310. * @param format defines the texture format to use
  51311. * @param scene defines the hosting scene
  51312. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51313. * @param invertY defines if texture must be stored with Y axis inverted
  51314. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51315. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51316. */
  51317. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51318. /** Gets or sets the texture format to use */
  51319. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51320. /**
  51321. * Update the texture with new data
  51322. * @param data defines the data to store in the texture
  51323. */
  51324. update(data: ArrayBufferView): void;
  51325. }
  51326. }
  51327. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51328. import { Scene } from "babylonjs/scene";
  51329. import { Plane } from "babylonjs/Maths/math";
  51330. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51331. /**
  51332. * Creates a refraction texture used by refraction channel of the standard material.
  51333. * It is like a mirror but to see through a material.
  51334. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51335. */
  51336. export class RefractionTexture extends RenderTargetTexture {
  51337. /**
  51338. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51339. * 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.
  51340. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51341. */
  51342. refractionPlane: Plane;
  51343. /**
  51344. * Define how deep under the surface we should see.
  51345. */
  51346. depth: number;
  51347. /**
  51348. * Creates a refraction texture used by refraction channel of the standard material.
  51349. * It is like a mirror but to see through a material.
  51350. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51351. * @param name Define the texture name
  51352. * @param size Define the size of the underlying texture
  51353. * @param scene Define the scene the refraction belongs to
  51354. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51355. */
  51356. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51357. /**
  51358. * Clone the refraction texture.
  51359. * @returns the cloned texture
  51360. */
  51361. clone(): RefractionTexture;
  51362. /**
  51363. * Serialize the texture to a JSON representation you could use in Parse later on
  51364. * @returns the serialized JSON representation
  51365. */
  51366. serialize(): any;
  51367. }
  51368. }
  51369. declare module "babylonjs/Materials/Textures/index" {
  51370. export * from "babylonjs/Materials/Textures/baseTexture";
  51371. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51372. export * from "babylonjs/Materials/Textures/cubeTexture";
  51373. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51374. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51375. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51376. export * from "babylonjs/Materials/Textures/internalTexture";
  51377. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51378. export * from "babylonjs/Materials/Textures/Loaders/index";
  51379. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51380. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51381. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51382. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51383. export * from "babylonjs/Materials/Textures/rawTexture";
  51384. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51385. export * from "babylonjs/Materials/Textures/refractionTexture";
  51386. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51387. export * from "babylonjs/Materials/Textures/texture";
  51388. export * from "babylonjs/Materials/Textures/videoTexture";
  51389. }
  51390. declare module "babylonjs/Materials/index" {
  51391. export * from "babylonjs/Materials/Background/index";
  51392. export * from "babylonjs/Materials/colorCurves";
  51393. export * from "babylonjs/Materials/effect";
  51394. export * from "babylonjs/Materials/fresnelParameters";
  51395. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51396. export * from "babylonjs/Materials/material";
  51397. export * from "babylonjs/Materials/materialDefines";
  51398. export * from "babylonjs/Materials/materialHelper";
  51399. export * from "babylonjs/Materials/multiMaterial";
  51400. export * from "babylonjs/Materials/PBR/index";
  51401. export * from "babylonjs/Materials/pushMaterial";
  51402. export * from "babylonjs/Materials/shaderMaterial";
  51403. export * from "babylonjs/Materials/standardMaterial";
  51404. export * from "babylonjs/Materials/Textures/index";
  51405. export * from "babylonjs/Materials/uniformBuffer";
  51406. export * from "babylonjs/Materials/materialFlags";
  51407. }
  51408. declare module "babylonjs/Maths/index" {
  51409. export * from "babylonjs/Maths/math.scalar";
  51410. export * from "babylonjs/Maths/math";
  51411. export * from "babylonjs/Maths/sphericalPolynomial";
  51412. }
  51413. declare module "babylonjs/Misc/workerPool" {
  51414. import { IDisposable } from "babylonjs/scene";
  51415. /**
  51416. * Helper class to push actions to a pool of workers.
  51417. */
  51418. export class WorkerPool implements IDisposable {
  51419. private _workerInfos;
  51420. private _pendingActions;
  51421. /**
  51422. * Constructor
  51423. * @param workers Array of workers to use for actions
  51424. */
  51425. constructor(workers: Array<Worker>);
  51426. /**
  51427. * Terminates all workers and clears any pending actions.
  51428. */
  51429. dispose(): void;
  51430. /**
  51431. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51432. * pended until a worker has completed its action.
  51433. * @param action The action to perform. Call onComplete when the action is complete.
  51434. */
  51435. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51436. private _execute;
  51437. }
  51438. }
  51439. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51440. import { IDisposable } from "babylonjs/scene";
  51441. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51442. /**
  51443. * Configuration for Draco compression
  51444. */
  51445. export interface IDracoCompressionConfiguration {
  51446. /**
  51447. * Configuration for the decoder.
  51448. */
  51449. decoder?: {
  51450. /**
  51451. * The url to the WebAssembly module.
  51452. */
  51453. wasmUrl?: string;
  51454. /**
  51455. * The url to the WebAssembly binary.
  51456. */
  51457. wasmBinaryUrl?: string;
  51458. /**
  51459. * The url to the fallback JavaScript module.
  51460. */
  51461. fallbackUrl?: string;
  51462. };
  51463. }
  51464. /**
  51465. * Draco compression (https://google.github.io/draco/)
  51466. *
  51467. * This class wraps the Draco module.
  51468. *
  51469. * **Encoder**
  51470. *
  51471. * The encoder is not currently implemented.
  51472. *
  51473. * **Decoder**
  51474. *
  51475. * 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.
  51476. *
  51477. * To update the configuration, use the following code:
  51478. * ```javascript
  51479. * DracoCompression.Configuration = {
  51480. * decoder: {
  51481. * wasmUrl: "<url to the WebAssembly library>",
  51482. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51483. * fallbackUrl: "<url to the fallback JavaScript library>",
  51484. * }
  51485. * };
  51486. * ```
  51487. *
  51488. * 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.
  51489. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51490. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51491. *
  51492. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51493. * ```javascript
  51494. * var dracoCompression = new DracoCompression();
  51495. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51496. * [VertexBuffer.PositionKind]: 0
  51497. * });
  51498. * ```
  51499. *
  51500. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51501. */
  51502. export class DracoCompression implements IDisposable {
  51503. private _workerPoolPromise;
  51504. /**
  51505. * The configuration. Defaults to the following urls:
  51506. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51507. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51508. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51509. */
  51510. static Configuration: IDracoCompressionConfiguration;
  51511. /**
  51512. * Returns true if the decoder is available.
  51513. */
  51514. static readonly DecoderAvailable: boolean;
  51515. /**
  51516. * Default number of workers to create when creating the draco compression object.
  51517. */
  51518. static DefaultNumWorkers: number;
  51519. private static GetDefaultNumWorkers;
  51520. /**
  51521. * Constructor
  51522. * @param numWorkers The number of workers for async operations
  51523. */
  51524. constructor(numWorkers?: number);
  51525. /**
  51526. * Stop all async operations and release resources.
  51527. */
  51528. dispose(): void;
  51529. /**
  51530. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51531. * @returns a promise that resolves when ready
  51532. */
  51533. whenReadyAsync(): Promise<void>;
  51534. /**
  51535. * Decode Draco compressed mesh data to vertex data.
  51536. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51537. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51538. * @returns A promise that resolves with the decoded vertex data
  51539. */
  51540. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51541. [kind: string]: number;
  51542. }): Promise<VertexData>;
  51543. /**
  51544. * The worker function that gets converted to a blob url to pass into a worker.
  51545. */
  51546. private static _Worker;
  51547. private _loadDecoderWasmBinaryAsync;
  51548. }
  51549. }
  51550. declare module "babylonjs/Meshes/Compression/index" {
  51551. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51552. }
  51553. declare module "babylonjs/Meshes/csg" {
  51554. import { Nullable } from "babylonjs/types";
  51555. import { Scene } from "babylonjs/scene";
  51556. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51557. import { Mesh } from "babylonjs/Meshes/mesh";
  51558. import { Material } from "babylonjs/Materials/material";
  51559. /**
  51560. * Class for building Constructive Solid Geometry
  51561. */
  51562. export class CSG {
  51563. private polygons;
  51564. /**
  51565. * The world matrix
  51566. */
  51567. matrix: Matrix;
  51568. /**
  51569. * Stores the position
  51570. */
  51571. position: Vector3;
  51572. /**
  51573. * Stores the rotation
  51574. */
  51575. rotation: Vector3;
  51576. /**
  51577. * Stores the rotation quaternion
  51578. */
  51579. rotationQuaternion: Nullable<Quaternion>;
  51580. /**
  51581. * Stores the scaling vector
  51582. */
  51583. scaling: Vector3;
  51584. /**
  51585. * Convert the Mesh to CSG
  51586. * @param mesh The Mesh to convert to CSG
  51587. * @returns A new CSG from the Mesh
  51588. */
  51589. static FromMesh(mesh: Mesh): CSG;
  51590. /**
  51591. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51592. * @param polygons Polygons used to construct a CSG solid
  51593. */
  51594. private static FromPolygons;
  51595. /**
  51596. * Clones, or makes a deep copy, of the CSG
  51597. * @returns A new CSG
  51598. */
  51599. clone(): CSG;
  51600. /**
  51601. * Unions this CSG with another CSG
  51602. * @param csg The CSG to union against this CSG
  51603. * @returns The unioned CSG
  51604. */
  51605. union(csg: CSG): CSG;
  51606. /**
  51607. * Unions this CSG with another CSG in place
  51608. * @param csg The CSG to union against this CSG
  51609. */
  51610. unionInPlace(csg: CSG): void;
  51611. /**
  51612. * Subtracts this CSG with another CSG
  51613. * @param csg The CSG to subtract against this CSG
  51614. * @returns A new CSG
  51615. */
  51616. subtract(csg: CSG): CSG;
  51617. /**
  51618. * Subtracts this CSG with another CSG in place
  51619. * @param csg The CSG to subtact against this CSG
  51620. */
  51621. subtractInPlace(csg: CSG): void;
  51622. /**
  51623. * Intersect this CSG with another CSG
  51624. * @param csg The CSG to intersect against this CSG
  51625. * @returns A new CSG
  51626. */
  51627. intersect(csg: CSG): CSG;
  51628. /**
  51629. * Intersects this CSG with another CSG in place
  51630. * @param csg The CSG to intersect against this CSG
  51631. */
  51632. intersectInPlace(csg: CSG): void;
  51633. /**
  51634. * Return a new CSG solid with solid and empty space switched. This solid is
  51635. * not modified.
  51636. * @returns A new CSG solid with solid and empty space switched
  51637. */
  51638. inverse(): CSG;
  51639. /**
  51640. * Inverses the CSG in place
  51641. */
  51642. inverseInPlace(): void;
  51643. /**
  51644. * This is used to keep meshes transformations so they can be restored
  51645. * when we build back a Babylon Mesh
  51646. * NB : All CSG operations are performed in world coordinates
  51647. * @param csg The CSG to copy the transform attributes from
  51648. * @returns This CSG
  51649. */
  51650. copyTransformAttributes(csg: CSG): CSG;
  51651. /**
  51652. * Build Raw mesh from CSG
  51653. * Coordinates here are in world space
  51654. * @param name The name of the mesh geometry
  51655. * @param scene The Scene
  51656. * @param keepSubMeshes Specifies if the submeshes should be kept
  51657. * @returns A new Mesh
  51658. */
  51659. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51660. /**
  51661. * Build Mesh from CSG taking material and transforms into account
  51662. * @param name The name of the Mesh
  51663. * @param material The material of the Mesh
  51664. * @param scene The Scene
  51665. * @param keepSubMeshes Specifies if submeshes should be kept
  51666. * @returns The new Mesh
  51667. */
  51668. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51669. }
  51670. }
  51671. declare module "babylonjs/Meshes/trailMesh" {
  51672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51673. import { Mesh } from "babylonjs/Meshes/mesh";
  51674. import { Scene } from "babylonjs/scene";
  51675. /**
  51676. * Class used to create a trail following a mesh
  51677. */
  51678. export class TrailMesh extends Mesh {
  51679. private _generator;
  51680. private _autoStart;
  51681. private _running;
  51682. private _diameter;
  51683. private _length;
  51684. private _sectionPolygonPointsCount;
  51685. private _sectionVectors;
  51686. private _sectionNormalVectors;
  51687. private _beforeRenderObserver;
  51688. /**
  51689. * @constructor
  51690. * @param name The value used by scene.getMeshByName() to do a lookup.
  51691. * @param generator The mesh to generate a trail.
  51692. * @param scene The scene to add this mesh to.
  51693. * @param diameter Diameter of trailing mesh. Default is 1.
  51694. * @param length Length of trailing mesh. Default is 60.
  51695. * @param autoStart Automatically start trailing mesh. Default true.
  51696. */
  51697. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51698. /**
  51699. * "TrailMesh"
  51700. * @returns "TrailMesh"
  51701. */
  51702. getClassName(): string;
  51703. private _createMesh;
  51704. /**
  51705. * Start trailing mesh.
  51706. */
  51707. start(): void;
  51708. /**
  51709. * Stop trailing mesh.
  51710. */
  51711. stop(): void;
  51712. /**
  51713. * Update trailing mesh geometry.
  51714. */
  51715. update(): void;
  51716. /**
  51717. * Returns a new TrailMesh object.
  51718. * @param name is a string, the name given to the new mesh
  51719. * @param newGenerator use new generator object for cloned trail mesh
  51720. * @returns a new mesh
  51721. */
  51722. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51723. /**
  51724. * Serializes this trail mesh
  51725. * @param serializationObject object to write serialization to
  51726. */
  51727. serialize(serializationObject: any): void;
  51728. /**
  51729. * Parses a serialized trail mesh
  51730. * @param parsedMesh the serialized mesh
  51731. * @param scene the scene to create the trail mesh in
  51732. * @returns the created trail mesh
  51733. */
  51734. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51735. }
  51736. }
  51737. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51738. import { Vector4 } from "babylonjs/Maths/math";
  51739. import { Mesh } from "babylonjs/Meshes/mesh";
  51740. /**
  51741. * Class containing static functions to help procedurally build meshes
  51742. */
  51743. export class TorusKnotBuilder {
  51744. /**
  51745. * Creates a torus knot mesh
  51746. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51747. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51748. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51749. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51753. * @param name defines the name of the mesh
  51754. * @param options defines the options used to create the mesh
  51755. * @param scene defines the hosting scene
  51756. * @returns the torus knot mesh
  51757. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51758. */
  51759. static CreateTorusKnot(name: string, options: {
  51760. radius?: number;
  51761. tube?: number;
  51762. radialSegments?: number;
  51763. tubularSegments?: number;
  51764. p?: number;
  51765. q?: number;
  51766. updatable?: boolean;
  51767. sideOrientation?: number;
  51768. frontUVs?: Vector4;
  51769. backUVs?: Vector4;
  51770. }, scene: any): Mesh;
  51771. }
  51772. }
  51773. declare module "babylonjs/Meshes/polygonMesh" {
  51774. import { Scene } from "babylonjs/scene";
  51775. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51776. import { Mesh } from "babylonjs/Meshes/mesh";
  51777. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51778. /**
  51779. * Polygon
  51780. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51781. */
  51782. export class Polygon {
  51783. /**
  51784. * Creates a rectangle
  51785. * @param xmin bottom X coord
  51786. * @param ymin bottom Y coord
  51787. * @param xmax top X coord
  51788. * @param ymax top Y coord
  51789. * @returns points that make the resulting rectation
  51790. */
  51791. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51792. /**
  51793. * Creates a circle
  51794. * @param radius radius of circle
  51795. * @param cx scale in x
  51796. * @param cy scale in y
  51797. * @param numberOfSides number of sides that make up the circle
  51798. * @returns points that make the resulting circle
  51799. */
  51800. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51801. /**
  51802. * Creates a polygon from input string
  51803. * @param input Input polygon data
  51804. * @returns the parsed points
  51805. */
  51806. static Parse(input: string): Vector2[];
  51807. /**
  51808. * Starts building a polygon from x and y coordinates
  51809. * @param x x coordinate
  51810. * @param y y coordinate
  51811. * @returns the started path2
  51812. */
  51813. static StartingAt(x: number, y: number): Path2;
  51814. }
  51815. /**
  51816. * Builds a polygon
  51817. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51818. */
  51819. export class PolygonMeshBuilder {
  51820. private _points;
  51821. private _outlinepoints;
  51822. private _holes;
  51823. private _name;
  51824. private _scene;
  51825. private _epoints;
  51826. private _eholes;
  51827. private _addToepoint;
  51828. /**
  51829. * Babylon reference to the earcut plugin.
  51830. */
  51831. bjsEarcut: any;
  51832. /**
  51833. * Creates a PolygonMeshBuilder
  51834. * @param name name of the builder
  51835. * @param contours Path of the polygon
  51836. * @param scene scene to add to when creating the mesh
  51837. * @param earcutInjection can be used to inject your own earcut reference
  51838. */
  51839. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51840. /**
  51841. * Adds a whole within the polygon
  51842. * @param hole Array of points defining the hole
  51843. * @returns this
  51844. */
  51845. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51846. /**
  51847. * Creates the polygon
  51848. * @param updatable If the mesh should be updatable
  51849. * @param depth The depth of the mesh created
  51850. * @returns the created mesh
  51851. */
  51852. build(updatable?: boolean, depth?: number): Mesh;
  51853. /**
  51854. * Creates the polygon
  51855. * @param depth The depth of the mesh created
  51856. * @returns the created VertexData
  51857. */
  51858. buildVertexData(depth?: number): VertexData;
  51859. /**
  51860. * Adds a side to the polygon
  51861. * @param positions points that make the polygon
  51862. * @param normals normals of the polygon
  51863. * @param uvs uvs of the polygon
  51864. * @param indices indices of the polygon
  51865. * @param bounds bounds of the polygon
  51866. * @param points points of the polygon
  51867. * @param depth depth of the polygon
  51868. * @param flip flip of the polygon
  51869. */
  51870. private addSide;
  51871. }
  51872. }
  51873. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  51874. import { Scene } from "babylonjs/scene";
  51875. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  51876. import { Mesh } from "babylonjs/Meshes/mesh";
  51877. import { Nullable } from "babylonjs/types";
  51878. /**
  51879. * Class containing static functions to help procedurally build meshes
  51880. */
  51881. export class PolygonBuilder {
  51882. /**
  51883. * Creates a polygon mesh
  51884. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51885. * * 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
  51886. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51889. * * Remember you can only change the shape positions, not their number when updating a polygon
  51890. * @param name defines the name of the mesh
  51891. * @param options defines the options used to create the mesh
  51892. * @param scene defines the hosting scene
  51893. * @param earcutInjection can be used to inject your own earcut reference
  51894. * @returns the polygon mesh
  51895. */
  51896. static CreatePolygon(name: string, options: {
  51897. shape: Vector3[];
  51898. holes?: Vector3[][];
  51899. depth?: number;
  51900. faceUV?: Vector4[];
  51901. faceColors?: Color4[];
  51902. updatable?: boolean;
  51903. sideOrientation?: number;
  51904. frontUVs?: Vector4;
  51905. backUVs?: Vector4;
  51906. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51907. /**
  51908. * Creates an extruded polygon mesh, with depth in the Y direction.
  51909. * * 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)
  51910. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51911. * @param name defines the name of the mesh
  51912. * @param options defines the options used to create the mesh
  51913. * @param scene defines the hosting scene
  51914. * @param earcutInjection can be used to inject your own earcut reference
  51915. * @returns the polygon mesh
  51916. */
  51917. static ExtrudePolygon(name: string, options: {
  51918. shape: Vector3[];
  51919. holes?: Vector3[][];
  51920. depth?: number;
  51921. faceUV?: Vector4[];
  51922. faceColors?: Color4[];
  51923. updatable?: boolean;
  51924. sideOrientation?: number;
  51925. frontUVs?: Vector4;
  51926. backUVs?: Vector4;
  51927. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51928. }
  51929. }
  51930. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  51931. import { Scene } from "babylonjs/scene";
  51932. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51933. import { Mesh } from "babylonjs/Meshes/mesh";
  51934. import { Nullable } from "babylonjs/types";
  51935. /**
  51936. * Class containing static functions to help procedurally build meshes
  51937. */
  51938. export class LatheBuilder {
  51939. /**
  51940. * Creates lathe mesh.
  51941. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51942. * * 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
  51943. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51944. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51945. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51946. * * 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
  51947. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51948. * * 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
  51949. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51950. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51951. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51953. * @param name defines the name of the mesh
  51954. * @param options defines the options used to create the mesh
  51955. * @param scene defines the hosting scene
  51956. * @returns the lathe mesh
  51957. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51958. */
  51959. static CreateLathe(name: string, options: {
  51960. shape: Vector3[];
  51961. radius?: number;
  51962. tessellation?: number;
  51963. clip?: number;
  51964. arc?: number;
  51965. closed?: boolean;
  51966. updatable?: boolean;
  51967. sideOrientation?: number;
  51968. frontUVs?: Vector4;
  51969. backUVs?: Vector4;
  51970. cap?: number;
  51971. invertUV?: boolean;
  51972. }, scene?: Nullable<Scene>): Mesh;
  51973. }
  51974. }
  51975. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  51976. import { Nullable } from "babylonjs/types";
  51977. import { Scene } from "babylonjs/scene";
  51978. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  51979. import { Mesh } from "babylonjs/Meshes/mesh";
  51980. /**
  51981. * Class containing static functions to help procedurally build meshes
  51982. */
  51983. export class TubeBuilder {
  51984. /**
  51985. * Creates a tube mesh.
  51986. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51987. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51988. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51989. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51990. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51991. * * 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)
  51992. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51993. * * 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
  51994. * * 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
  51995. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51996. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51997. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51998. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51999. * @param name defines the name of the mesh
  52000. * @param options defines the options used to create the mesh
  52001. * @param scene defines the hosting scene
  52002. * @returns the tube mesh
  52003. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52004. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52005. */
  52006. static CreateTube(name: string, options: {
  52007. path: Vector3[];
  52008. radius?: number;
  52009. tessellation?: number;
  52010. radiusFunction?: {
  52011. (i: number, distance: number): number;
  52012. };
  52013. cap?: number;
  52014. arc?: number;
  52015. updatable?: boolean;
  52016. sideOrientation?: number;
  52017. frontUVs?: Vector4;
  52018. backUVs?: Vector4;
  52019. instance?: Mesh;
  52020. invertUV?: boolean;
  52021. }, scene?: Nullable<Scene>): Mesh;
  52022. }
  52023. }
  52024. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52025. import { Scene } from "babylonjs/scene";
  52026. import { Vector4 } from "babylonjs/Maths/math";
  52027. import { Mesh } from "babylonjs/Meshes/mesh";
  52028. import { Nullable } from "babylonjs/types";
  52029. /**
  52030. * Class containing static functions to help procedurally build meshes
  52031. */
  52032. export class IcoSphereBuilder {
  52033. /**
  52034. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52035. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52036. * * 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`)
  52037. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52038. * * 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
  52039. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52040. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52041. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52042. * @param name defines the name of the mesh
  52043. * @param options defines the options used to create the mesh
  52044. * @param scene defines the hosting scene
  52045. * @returns the icosahedron mesh
  52046. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52047. */
  52048. static CreateIcoSphere(name: string, options: {
  52049. radius?: number;
  52050. radiusX?: number;
  52051. radiusY?: number;
  52052. radiusZ?: number;
  52053. flat?: boolean;
  52054. subdivisions?: number;
  52055. sideOrientation?: number;
  52056. frontUVs?: Vector4;
  52057. backUVs?: Vector4;
  52058. updatable?: boolean;
  52059. }, scene?: Nullable<Scene>): Mesh;
  52060. }
  52061. }
  52062. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52063. import { Vector3 } from "babylonjs/Maths/math";
  52064. import { Mesh } from "babylonjs/Meshes/mesh";
  52065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52066. /**
  52067. * Class containing static functions to help procedurally build meshes
  52068. */
  52069. export class DecalBuilder {
  52070. /**
  52071. * Creates a decal mesh.
  52072. * 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
  52073. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52074. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52075. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52076. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52077. * @param name defines the name of the mesh
  52078. * @param sourceMesh defines the mesh where the decal must be applied
  52079. * @param options defines the options used to create the mesh
  52080. * @param scene defines the hosting scene
  52081. * @returns the decal mesh
  52082. * @see https://doc.babylonjs.com/how_to/decals
  52083. */
  52084. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52085. position?: Vector3;
  52086. normal?: Vector3;
  52087. size?: Vector3;
  52088. angle?: number;
  52089. }): Mesh;
  52090. }
  52091. }
  52092. declare module "babylonjs/Meshes/meshBuilder" {
  52093. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52094. import { Nullable } from "babylonjs/types";
  52095. import { Scene } from "babylonjs/scene";
  52096. import { Mesh } from "babylonjs/Meshes/mesh";
  52097. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52098. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52100. /**
  52101. * Class containing static functions to help procedurally build meshes
  52102. */
  52103. export class MeshBuilder {
  52104. /**
  52105. * Creates a box mesh
  52106. * * The parameter `size` sets the size (float) of each box side (default 1)
  52107. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52108. * * 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)
  52109. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52111. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52113. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52114. * @param name defines the name of the mesh
  52115. * @param options defines the options used to create the mesh
  52116. * @param scene defines the hosting scene
  52117. * @returns the box mesh
  52118. */
  52119. static CreateBox(name: string, options: {
  52120. size?: number;
  52121. width?: number;
  52122. height?: number;
  52123. depth?: number;
  52124. faceUV?: Vector4[];
  52125. faceColors?: Color4[];
  52126. sideOrientation?: number;
  52127. frontUVs?: Vector4;
  52128. backUVs?: Vector4;
  52129. updatable?: boolean;
  52130. }, scene?: Nullable<Scene>): Mesh;
  52131. /**
  52132. * Creates a sphere mesh
  52133. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52134. * * 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`)
  52135. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52136. * * 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
  52137. * * 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)
  52138. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52139. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52141. * @param name defines the name of the mesh
  52142. * @param options defines the options used to create the mesh
  52143. * @param scene defines the hosting scene
  52144. * @returns the sphere mesh
  52145. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52146. */
  52147. static CreateSphere(name: string, options: {
  52148. segments?: number;
  52149. diameter?: number;
  52150. diameterX?: number;
  52151. diameterY?: number;
  52152. diameterZ?: number;
  52153. arc?: number;
  52154. slice?: number;
  52155. sideOrientation?: number;
  52156. frontUVs?: Vector4;
  52157. backUVs?: Vector4;
  52158. updatable?: boolean;
  52159. }, scene?: Nullable<Scene>): Mesh;
  52160. /**
  52161. * Creates a plane polygonal mesh. By default, this is a disc
  52162. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52163. * * 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
  52164. * * 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
  52165. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52166. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52168. * @param name defines the name of the mesh
  52169. * @param options defines the options used to create the mesh
  52170. * @param scene defines the hosting scene
  52171. * @returns the plane polygonal mesh
  52172. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52173. */
  52174. static CreateDisc(name: string, options: {
  52175. radius?: number;
  52176. tessellation?: number;
  52177. arc?: number;
  52178. updatable?: boolean;
  52179. sideOrientation?: number;
  52180. frontUVs?: Vector4;
  52181. backUVs?: Vector4;
  52182. }, scene?: Nullable<Scene>): Mesh;
  52183. /**
  52184. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52185. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52186. * * 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`)
  52187. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52188. * * 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
  52189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52191. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52192. * @param name defines the name of the mesh
  52193. * @param options defines the options used to create the mesh
  52194. * @param scene defines the hosting scene
  52195. * @returns the icosahedron mesh
  52196. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52197. */
  52198. static CreateIcoSphere(name: string, options: {
  52199. radius?: number;
  52200. radiusX?: number;
  52201. radiusY?: number;
  52202. radiusZ?: number;
  52203. flat?: boolean;
  52204. subdivisions?: number;
  52205. sideOrientation?: number;
  52206. frontUVs?: Vector4;
  52207. backUVs?: Vector4;
  52208. updatable?: boolean;
  52209. }, scene?: Nullable<Scene>): Mesh;
  52210. /**
  52211. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52212. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52213. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52214. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52215. * * 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
  52216. * * 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
  52217. * * 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
  52218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52221. * * 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
  52222. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52223. * * 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
  52224. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52226. * @param name defines the name of the mesh
  52227. * @param options defines the options used to create the mesh
  52228. * @param scene defines the hosting scene
  52229. * @returns the ribbon mesh
  52230. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52231. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52232. */
  52233. static CreateRibbon(name: string, options: {
  52234. pathArray: Vector3[][];
  52235. closeArray?: boolean;
  52236. closePath?: boolean;
  52237. offset?: number;
  52238. updatable?: boolean;
  52239. sideOrientation?: number;
  52240. frontUVs?: Vector4;
  52241. backUVs?: Vector4;
  52242. instance?: Mesh;
  52243. invertUV?: boolean;
  52244. uvs?: Vector2[];
  52245. colors?: Color4[];
  52246. }, scene?: Nullable<Scene>): Mesh;
  52247. /**
  52248. * Creates a cylinder or a cone mesh
  52249. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52250. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52251. * * 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.
  52252. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52253. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52254. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52255. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52256. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52257. * * 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).
  52258. * * 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
  52259. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52260. * * 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
  52261. * * 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.
  52262. * * If `enclose` is false, a ring surface is one element.
  52263. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52264. * * 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
  52265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52268. * @param name defines the name of the mesh
  52269. * @param options defines the options used to create the mesh
  52270. * @param scene defines the hosting scene
  52271. * @returns the cylinder mesh
  52272. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52273. */
  52274. static CreateCylinder(name: string, options: {
  52275. height?: number;
  52276. diameterTop?: number;
  52277. diameterBottom?: number;
  52278. diameter?: number;
  52279. tessellation?: number;
  52280. subdivisions?: number;
  52281. arc?: number;
  52282. faceColors?: Color4[];
  52283. faceUV?: Vector4[];
  52284. updatable?: boolean;
  52285. hasRings?: boolean;
  52286. enclose?: boolean;
  52287. sideOrientation?: number;
  52288. frontUVs?: Vector4;
  52289. backUVs?: Vector4;
  52290. }, scene?: Nullable<Scene>): Mesh;
  52291. /**
  52292. * Creates a torus mesh
  52293. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52294. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52295. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52299. * @param name defines the name of the mesh
  52300. * @param options defines the options used to create the mesh
  52301. * @param scene defines the hosting scene
  52302. * @returns the torus mesh
  52303. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52304. */
  52305. static CreateTorus(name: string, options: {
  52306. diameter?: number;
  52307. thickness?: number;
  52308. tessellation?: number;
  52309. updatable?: boolean;
  52310. sideOrientation?: number;
  52311. frontUVs?: Vector4;
  52312. backUVs?: Vector4;
  52313. }, scene?: Nullable<Scene>): Mesh;
  52314. /**
  52315. * Creates a torus knot mesh
  52316. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52317. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52318. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52319. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52321. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52323. * @param name defines the name of the mesh
  52324. * @param options defines the options used to create the mesh
  52325. * @param scene defines the hosting scene
  52326. * @returns the torus knot mesh
  52327. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52328. */
  52329. static CreateTorusKnot(name: string, options: {
  52330. radius?: number;
  52331. tube?: number;
  52332. radialSegments?: number;
  52333. tubularSegments?: number;
  52334. p?: number;
  52335. q?: number;
  52336. updatable?: boolean;
  52337. sideOrientation?: number;
  52338. frontUVs?: Vector4;
  52339. backUVs?: Vector4;
  52340. }, scene?: Nullable<Scene>): Mesh;
  52341. /**
  52342. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52343. * * 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
  52344. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52345. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52346. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52347. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52348. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52349. * * 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
  52350. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52352. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52353. * @param name defines the name of the new line system
  52354. * @param options defines the options used to create the line system
  52355. * @param scene defines the hosting scene
  52356. * @returns a new line system mesh
  52357. */
  52358. static CreateLineSystem(name: string, options: {
  52359. lines: Vector3[][];
  52360. updatable?: boolean;
  52361. instance?: Nullable<LinesMesh>;
  52362. colors?: Nullable<Color4[][]>;
  52363. useVertexAlpha?: boolean;
  52364. }, scene: Nullable<Scene>): LinesMesh;
  52365. /**
  52366. * Creates a line mesh
  52367. * 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
  52368. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52369. * * The parameter `points` is an array successive Vector3
  52370. * * 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
  52371. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52372. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52373. * * When updating an instance, remember that only point positions can change, not the number of points
  52374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52375. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52376. * @param name defines the name of the new line system
  52377. * @param options defines the options used to create the line system
  52378. * @param scene defines the hosting scene
  52379. * @returns a new line mesh
  52380. */
  52381. static CreateLines(name: string, options: {
  52382. points: Vector3[];
  52383. updatable?: boolean;
  52384. instance?: Nullable<LinesMesh>;
  52385. colors?: Color4[];
  52386. useVertexAlpha?: boolean;
  52387. }, scene?: Nullable<Scene>): LinesMesh;
  52388. /**
  52389. * Creates a dashed line mesh
  52390. * * 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
  52391. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52392. * * The parameter `points` is an array successive Vector3
  52393. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52394. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52395. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52396. * * 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
  52397. * * When updating an instance, remember that only point positions can change, not the number of points
  52398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52399. * @param name defines the name of the mesh
  52400. * @param options defines the options used to create the mesh
  52401. * @param scene defines the hosting scene
  52402. * @returns the dashed line mesh
  52403. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52404. */
  52405. static CreateDashedLines(name: string, options: {
  52406. points: Vector3[];
  52407. dashSize?: number;
  52408. gapSize?: number;
  52409. dashNb?: number;
  52410. updatable?: boolean;
  52411. instance?: LinesMesh;
  52412. }, scene?: Nullable<Scene>): LinesMesh;
  52413. /**
  52414. * 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.
  52415. * * 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.
  52416. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52417. * * 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.
  52418. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52419. * * 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
  52420. * * 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
  52421. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52424. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52426. * @param name defines the name of the mesh
  52427. * @param options defines the options used to create the mesh
  52428. * @param scene defines the hosting scene
  52429. * @returns the extruded shape mesh
  52430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52432. */
  52433. static ExtrudeShape(name: string, options: {
  52434. shape: Vector3[];
  52435. path: Vector3[];
  52436. scale?: number;
  52437. rotation?: number;
  52438. cap?: number;
  52439. updatable?: boolean;
  52440. sideOrientation?: number;
  52441. frontUVs?: Vector4;
  52442. backUVs?: Vector4;
  52443. instance?: Mesh;
  52444. invertUV?: boolean;
  52445. }, scene?: Nullable<Scene>): Mesh;
  52446. /**
  52447. * Creates an custom extruded shape mesh.
  52448. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52449. * * 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.
  52450. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52451. * * 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
  52452. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52453. * * 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
  52454. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52455. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52456. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52457. * * 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
  52458. * * 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
  52459. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52462. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52464. * @param name defines the name of the mesh
  52465. * @param options defines the options used to create the mesh
  52466. * @param scene defines the hosting scene
  52467. * @returns the custom extruded shape mesh
  52468. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52470. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52471. */
  52472. static ExtrudeShapeCustom(name: string, options: {
  52473. shape: Vector3[];
  52474. path: Vector3[];
  52475. scaleFunction?: any;
  52476. rotationFunction?: any;
  52477. ribbonCloseArray?: boolean;
  52478. ribbonClosePath?: boolean;
  52479. cap?: number;
  52480. updatable?: boolean;
  52481. sideOrientation?: number;
  52482. frontUVs?: Vector4;
  52483. backUVs?: Vector4;
  52484. instance?: Mesh;
  52485. invertUV?: boolean;
  52486. }, scene?: Nullable<Scene>): Mesh;
  52487. /**
  52488. * Creates lathe mesh.
  52489. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52490. * * 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
  52491. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52492. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52493. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52494. * * 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
  52495. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52496. * * 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
  52497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52499. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52501. * @param name defines the name of the mesh
  52502. * @param options defines the options used to create the mesh
  52503. * @param scene defines the hosting scene
  52504. * @returns the lathe mesh
  52505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52506. */
  52507. static CreateLathe(name: string, options: {
  52508. shape: Vector3[];
  52509. radius?: number;
  52510. tessellation?: number;
  52511. clip?: number;
  52512. arc?: number;
  52513. closed?: boolean;
  52514. updatable?: boolean;
  52515. sideOrientation?: number;
  52516. frontUVs?: Vector4;
  52517. backUVs?: Vector4;
  52518. cap?: number;
  52519. invertUV?: boolean;
  52520. }, scene?: Nullable<Scene>): Mesh;
  52521. /**
  52522. * Creates a plane mesh
  52523. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52524. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52525. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52527. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52529. * @param name defines the name of the mesh
  52530. * @param options defines the options used to create the mesh
  52531. * @param scene defines the hosting scene
  52532. * @returns the plane mesh
  52533. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52534. */
  52535. static CreatePlane(name: string, options: {
  52536. size?: number;
  52537. width?: number;
  52538. height?: number;
  52539. sideOrientation?: number;
  52540. frontUVs?: Vector4;
  52541. backUVs?: Vector4;
  52542. updatable?: boolean;
  52543. sourcePlane?: Plane;
  52544. }, scene?: Nullable<Scene>): Mesh;
  52545. /**
  52546. * Creates a ground mesh
  52547. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52548. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52550. * @param name defines the name of the mesh
  52551. * @param options defines the options used to create the mesh
  52552. * @param scene defines the hosting scene
  52553. * @returns the ground mesh
  52554. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52555. */
  52556. static CreateGround(name: string, options: {
  52557. width?: number;
  52558. height?: number;
  52559. subdivisions?: number;
  52560. subdivisionsX?: number;
  52561. subdivisionsY?: number;
  52562. updatable?: boolean;
  52563. }, scene?: Nullable<Scene>): Mesh;
  52564. /**
  52565. * Creates a tiled ground mesh
  52566. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52567. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52568. * * 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
  52569. * * 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
  52570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52571. * @param name defines the name of the mesh
  52572. * @param options defines the options used to create the mesh
  52573. * @param scene defines the hosting scene
  52574. * @returns the tiled ground mesh
  52575. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52576. */
  52577. static CreateTiledGround(name: string, options: {
  52578. xmin: number;
  52579. zmin: number;
  52580. xmax: number;
  52581. zmax: number;
  52582. subdivisions?: {
  52583. w: number;
  52584. h: number;
  52585. };
  52586. precision?: {
  52587. w: number;
  52588. h: number;
  52589. };
  52590. updatable?: boolean;
  52591. }, scene?: Nullable<Scene>): Mesh;
  52592. /**
  52593. * Creates a ground mesh from a height map
  52594. * * The parameter `url` sets the URL of the height map image resource.
  52595. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52596. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52597. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52598. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52599. * * 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.
  52600. * * 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).
  52601. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52602. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52603. * @param name defines the name of the mesh
  52604. * @param url defines the url to the height map
  52605. * @param options defines the options used to create the mesh
  52606. * @param scene defines the hosting scene
  52607. * @returns the ground mesh
  52608. * @see https://doc.babylonjs.com/babylon101/height_map
  52609. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52610. */
  52611. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52612. width?: number;
  52613. height?: number;
  52614. subdivisions?: number;
  52615. minHeight?: number;
  52616. maxHeight?: number;
  52617. colorFilter?: Color3;
  52618. alphaFilter?: number;
  52619. updatable?: boolean;
  52620. onReady?: (mesh: GroundMesh) => void;
  52621. }, scene?: Nullable<Scene>): GroundMesh;
  52622. /**
  52623. * Creates a polygon mesh
  52624. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52625. * * 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
  52626. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52628. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52629. * * Remember you can only change the shape positions, not their number when updating a polygon
  52630. * @param name defines the name of the mesh
  52631. * @param options defines the options used to create the mesh
  52632. * @param scene defines the hosting scene
  52633. * @param earcutInjection can be used to inject your own earcut reference
  52634. * @returns the polygon mesh
  52635. */
  52636. static CreatePolygon(name: string, options: {
  52637. shape: Vector3[];
  52638. holes?: Vector3[][];
  52639. depth?: number;
  52640. faceUV?: Vector4[];
  52641. faceColors?: Color4[];
  52642. updatable?: boolean;
  52643. sideOrientation?: number;
  52644. frontUVs?: Vector4;
  52645. backUVs?: Vector4;
  52646. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52647. /**
  52648. * Creates an extruded polygon mesh, with depth in the Y direction.
  52649. * * 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)
  52650. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52651. * @param name defines the name of the mesh
  52652. * @param options defines the options used to create the mesh
  52653. * @param scene defines the hosting scene
  52654. * @param earcutInjection can be used to inject your own earcut reference
  52655. * @returns the polygon mesh
  52656. */
  52657. static ExtrudePolygon(name: string, options: {
  52658. shape: Vector3[];
  52659. holes?: Vector3[][];
  52660. depth?: number;
  52661. faceUV?: Vector4[];
  52662. faceColors?: Color4[];
  52663. updatable?: boolean;
  52664. sideOrientation?: number;
  52665. frontUVs?: Vector4;
  52666. backUVs?: Vector4;
  52667. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52668. /**
  52669. * Creates a tube mesh.
  52670. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52671. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52672. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52673. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52674. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52675. * * 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)
  52676. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52677. * * 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
  52678. * * 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
  52679. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52680. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52681. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52682. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52683. * @param name defines the name of the mesh
  52684. * @param options defines the options used to create the mesh
  52685. * @param scene defines the hosting scene
  52686. * @returns the tube mesh
  52687. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52688. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52689. */
  52690. static CreateTube(name: string, options: {
  52691. path: Vector3[];
  52692. radius?: number;
  52693. tessellation?: number;
  52694. radiusFunction?: {
  52695. (i: number, distance: number): number;
  52696. };
  52697. cap?: number;
  52698. arc?: number;
  52699. updatable?: boolean;
  52700. sideOrientation?: number;
  52701. frontUVs?: Vector4;
  52702. backUVs?: Vector4;
  52703. instance?: Mesh;
  52704. invertUV?: boolean;
  52705. }, scene?: Nullable<Scene>): Mesh;
  52706. /**
  52707. * Creates a polyhedron mesh
  52708. * * 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
  52709. * * The parameter `size` (positive float, default 1) sets the polygon size
  52710. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52711. * * 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`
  52712. * * 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
  52713. * * 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)`)
  52714. * * 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
  52715. * * 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
  52716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52719. * @param name defines the name of the mesh
  52720. * @param options defines the options used to create the mesh
  52721. * @param scene defines the hosting scene
  52722. * @returns the polyhedron mesh
  52723. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52724. */
  52725. static CreatePolyhedron(name: string, options: {
  52726. type?: number;
  52727. size?: number;
  52728. sizeX?: number;
  52729. sizeY?: number;
  52730. sizeZ?: number;
  52731. custom?: any;
  52732. faceUV?: Vector4[];
  52733. faceColors?: Color4[];
  52734. flat?: boolean;
  52735. updatable?: boolean;
  52736. sideOrientation?: number;
  52737. frontUVs?: Vector4;
  52738. backUVs?: Vector4;
  52739. }, scene?: Nullable<Scene>): Mesh;
  52740. /**
  52741. * Creates a decal mesh.
  52742. * 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
  52743. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52744. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52745. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52746. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52747. * @param name defines the name of the mesh
  52748. * @param sourceMesh defines the mesh where the decal must be applied
  52749. * @param options defines the options used to create the mesh
  52750. * @param scene defines the hosting scene
  52751. * @returns the decal mesh
  52752. * @see https://doc.babylonjs.com/how_to/decals
  52753. */
  52754. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52755. position?: Vector3;
  52756. normal?: Vector3;
  52757. size?: Vector3;
  52758. angle?: number;
  52759. }): Mesh;
  52760. }
  52761. }
  52762. declare module "babylonjs/Meshes/meshSimplification" {
  52763. import { Mesh } from "babylonjs/Meshes/mesh";
  52764. /**
  52765. * A simplifier interface for future simplification implementations
  52766. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52767. */
  52768. export interface ISimplifier {
  52769. /**
  52770. * Simplification of a given mesh according to the given settings.
  52771. * Since this requires computation, it is assumed that the function runs async.
  52772. * @param settings The settings of the simplification, including quality and distance
  52773. * @param successCallback A callback that will be called after the mesh was simplified.
  52774. * @param errorCallback in case of an error, this callback will be called. optional.
  52775. */
  52776. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52777. }
  52778. /**
  52779. * Expected simplification settings.
  52780. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52781. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52782. */
  52783. export interface ISimplificationSettings {
  52784. /**
  52785. * Gets or sets the expected quality
  52786. */
  52787. quality: number;
  52788. /**
  52789. * Gets or sets the distance when this optimized version should be used
  52790. */
  52791. distance: number;
  52792. /**
  52793. * Gets an already optimized mesh
  52794. */
  52795. optimizeMesh?: boolean;
  52796. }
  52797. /**
  52798. * Class used to specify simplification options
  52799. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52800. */
  52801. export class SimplificationSettings implements ISimplificationSettings {
  52802. /** expected quality */
  52803. quality: number;
  52804. /** distance when this optimized version should be used */
  52805. distance: number;
  52806. /** already optimized mesh */
  52807. optimizeMesh?: boolean | undefined;
  52808. /**
  52809. * Creates a SimplificationSettings
  52810. * @param quality expected quality
  52811. * @param distance distance when this optimized version should be used
  52812. * @param optimizeMesh already optimized mesh
  52813. */
  52814. constructor(
  52815. /** expected quality */
  52816. quality: number,
  52817. /** distance when this optimized version should be used */
  52818. distance: number,
  52819. /** already optimized mesh */
  52820. optimizeMesh?: boolean | undefined);
  52821. }
  52822. /**
  52823. * Interface used to define a simplification task
  52824. */
  52825. export interface ISimplificationTask {
  52826. /**
  52827. * Array of settings
  52828. */
  52829. settings: Array<ISimplificationSettings>;
  52830. /**
  52831. * Simplification type
  52832. */
  52833. simplificationType: SimplificationType;
  52834. /**
  52835. * Mesh to simplify
  52836. */
  52837. mesh: Mesh;
  52838. /**
  52839. * Callback called on success
  52840. */
  52841. successCallback?: () => void;
  52842. /**
  52843. * Defines if parallel processing can be used
  52844. */
  52845. parallelProcessing: boolean;
  52846. }
  52847. /**
  52848. * Queue used to order the simplification tasks
  52849. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52850. */
  52851. export class SimplificationQueue {
  52852. private _simplificationArray;
  52853. /**
  52854. * Gets a boolean indicating that the process is still running
  52855. */
  52856. running: boolean;
  52857. /**
  52858. * Creates a new queue
  52859. */
  52860. constructor();
  52861. /**
  52862. * Adds a new simplification task
  52863. * @param task defines a task to add
  52864. */
  52865. addTask(task: ISimplificationTask): void;
  52866. /**
  52867. * Execute next task
  52868. */
  52869. executeNext(): void;
  52870. /**
  52871. * Execute a simplification task
  52872. * @param task defines the task to run
  52873. */
  52874. runSimplification(task: ISimplificationTask): void;
  52875. private getSimplifier;
  52876. }
  52877. /**
  52878. * The implemented types of simplification
  52879. * At the moment only Quadratic Error Decimation is implemented
  52880. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52881. */
  52882. export enum SimplificationType {
  52883. /** Quadratic error decimation */
  52884. QUADRATIC = 0
  52885. }
  52886. }
  52887. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  52888. import { Scene } from "babylonjs/scene";
  52889. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  52890. import { ISceneComponent } from "babylonjs/sceneComponent";
  52891. module "babylonjs/scene" {
  52892. interface Scene {
  52893. /** @hidden (Backing field) */
  52894. _simplificationQueue: SimplificationQueue;
  52895. /**
  52896. * Gets or sets the simplification queue attached to the scene
  52897. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52898. */
  52899. simplificationQueue: SimplificationQueue;
  52900. }
  52901. }
  52902. module "babylonjs/Meshes/mesh" {
  52903. interface Mesh {
  52904. /**
  52905. * Simplify the mesh according to the given array of settings.
  52906. * Function will return immediately and will simplify async
  52907. * @param settings a collection of simplification settings
  52908. * @param parallelProcessing should all levels calculate parallel or one after the other
  52909. * @param simplificationType the type of simplification to run
  52910. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52911. * @returns the current mesh
  52912. */
  52913. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52914. }
  52915. }
  52916. /**
  52917. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52918. * created in a scene
  52919. */
  52920. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52921. /**
  52922. * The component name helpfull to identify the component in the list of scene components.
  52923. */
  52924. readonly name: string;
  52925. /**
  52926. * The scene the component belongs to.
  52927. */
  52928. scene: Scene;
  52929. /**
  52930. * Creates a new instance of the component for the given scene
  52931. * @param scene Defines the scene to register the component in
  52932. */
  52933. constructor(scene: Scene);
  52934. /**
  52935. * Registers the component in a given scene
  52936. */
  52937. register(): void;
  52938. /**
  52939. * Rebuilds the elements related to this component in case of
  52940. * context lost for instance.
  52941. */
  52942. rebuild(): void;
  52943. /**
  52944. * Disposes the component and the associated ressources
  52945. */
  52946. dispose(): void;
  52947. private _beforeCameraUpdate;
  52948. }
  52949. }
  52950. declare module "babylonjs/Meshes/Builders/index" {
  52951. export * from "babylonjs/Meshes/Builders/boxBuilder";
  52952. export * from "babylonjs/Meshes/Builders/discBuilder";
  52953. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  52954. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  52955. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  52956. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  52957. export * from "babylonjs/Meshes/Builders/torusBuilder";
  52958. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  52959. export * from "babylonjs/Meshes/Builders/linesBuilder";
  52960. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  52961. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  52962. export * from "babylonjs/Meshes/Builders/latheBuilder";
  52963. export * from "babylonjs/Meshes/Builders/planeBuilder";
  52964. export * from "babylonjs/Meshes/Builders/groundBuilder";
  52965. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  52966. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  52967. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  52968. export * from "babylonjs/Meshes/Builders/decalBuilder";
  52969. }
  52970. declare module "babylonjs/Meshes/index" {
  52971. export * from "babylonjs/Meshes/abstractMesh";
  52972. export * from "babylonjs/Meshes/buffer";
  52973. export * from "babylonjs/Meshes/Compression/index";
  52974. export * from "babylonjs/Meshes/csg";
  52975. export * from "babylonjs/Meshes/geometry";
  52976. export * from "babylonjs/Meshes/groundMesh";
  52977. export * from "babylonjs/Meshes/trailMesh";
  52978. export * from "babylonjs/Meshes/instancedMesh";
  52979. export * from "babylonjs/Meshes/linesMesh";
  52980. export * from "babylonjs/Meshes/mesh";
  52981. export * from "babylonjs/Meshes/mesh.vertexData";
  52982. export * from "babylonjs/Meshes/meshBuilder";
  52983. export * from "babylonjs/Meshes/meshSimplification";
  52984. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  52985. export * from "babylonjs/Meshes/polygonMesh";
  52986. export * from "babylonjs/Meshes/subMesh";
  52987. export * from "babylonjs/Meshes/transformNode";
  52988. export * from "babylonjs/Meshes/Builders/index";
  52989. }
  52990. declare module "babylonjs/Morph/index" {
  52991. export * from "babylonjs/Morph/morphTarget";
  52992. export * from "babylonjs/Morph/morphTargetManager";
  52993. }
  52994. declare module "babylonjs/Offline/database" {
  52995. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  52996. /**
  52997. * Class used to enable access to IndexedDB
  52998. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52999. */
  53000. export class Database implements IOfflineProvider {
  53001. private _callbackManifestChecked;
  53002. private _currentSceneUrl;
  53003. private _db;
  53004. private _enableSceneOffline;
  53005. private _enableTexturesOffline;
  53006. private _manifestVersionFound;
  53007. private _mustUpdateRessources;
  53008. private _hasReachedQuota;
  53009. private _isSupported;
  53010. private _idbFactory;
  53011. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53012. private static IsUASupportingBlobStorage;
  53013. /**
  53014. * Gets a boolean indicating if Database storate is enabled (off by default)
  53015. */
  53016. static IDBStorageEnabled: boolean;
  53017. /**
  53018. * Gets a boolean indicating if scene must be saved in the database
  53019. */
  53020. readonly enableSceneOffline: boolean;
  53021. /**
  53022. * Gets a boolean indicating if textures must be saved in the database
  53023. */
  53024. readonly enableTexturesOffline: boolean;
  53025. /**
  53026. * Creates a new Database
  53027. * @param urlToScene defines the url to load the scene
  53028. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53029. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53030. */
  53031. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53032. private static _ParseURL;
  53033. private static _ReturnFullUrlLocation;
  53034. private _checkManifestFile;
  53035. /**
  53036. * Open the database and make it available
  53037. * @param successCallback defines the callback to call on success
  53038. * @param errorCallback defines the callback to call on error
  53039. */
  53040. open(successCallback: () => void, errorCallback: () => void): void;
  53041. /**
  53042. * Loads an image from the database
  53043. * @param url defines the url to load from
  53044. * @param image defines the target DOM image
  53045. */
  53046. loadImage(url: string, image: HTMLImageElement): void;
  53047. private _loadImageFromDBAsync;
  53048. private _saveImageIntoDBAsync;
  53049. private _checkVersionFromDB;
  53050. private _loadVersionFromDBAsync;
  53051. private _saveVersionIntoDBAsync;
  53052. /**
  53053. * Loads a file from database
  53054. * @param url defines the URL to load from
  53055. * @param sceneLoaded defines a callback to call on success
  53056. * @param progressCallBack defines a callback to call when progress changed
  53057. * @param errorCallback defines a callback to call on error
  53058. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53059. */
  53060. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53061. private _loadFileAsync;
  53062. private _saveFileAsync;
  53063. /**
  53064. * Validates if xhr data is correct
  53065. * @param xhr defines the request to validate
  53066. * @param dataType defines the expected data type
  53067. * @returns true if data is correct
  53068. */
  53069. private static _ValidateXHRData;
  53070. }
  53071. }
  53072. declare module "babylonjs/Offline/index" {
  53073. export * from "babylonjs/Offline/database";
  53074. export * from "babylonjs/Offline/IOfflineProvider";
  53075. }
  53076. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53077. /** @hidden */
  53078. export var gpuUpdateParticlesPixelShader: {
  53079. name: string;
  53080. shader: string;
  53081. };
  53082. }
  53083. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53084. /** @hidden */
  53085. export var gpuUpdateParticlesVertexShader: {
  53086. name: string;
  53087. shader: string;
  53088. };
  53089. }
  53090. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53091. /** @hidden */
  53092. export var clipPlaneFragmentDeclaration2: {
  53093. name: string;
  53094. shader: string;
  53095. };
  53096. }
  53097. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53098. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53099. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53100. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53101. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53102. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53103. /** @hidden */
  53104. export var gpuRenderParticlesPixelShader: {
  53105. name: string;
  53106. shader: string;
  53107. };
  53108. }
  53109. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53110. /** @hidden */
  53111. export var clipPlaneVertexDeclaration2: {
  53112. name: string;
  53113. shader: string;
  53114. };
  53115. }
  53116. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53117. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53118. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53119. /** @hidden */
  53120. export var gpuRenderParticlesVertexShader: {
  53121. name: string;
  53122. shader: string;
  53123. };
  53124. }
  53125. declare module "babylonjs/Particles/gpuParticleSystem" {
  53126. import { Nullable } from "babylonjs/types";
  53127. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53128. import { Observable } from "babylonjs/Misc/observable";
  53129. import { Color4, Color3 } from "babylonjs/Maths/math";
  53130. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53131. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53132. import { Scene, IDisposable } from "babylonjs/scene";
  53133. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53134. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53135. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53136. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53137. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53138. /**
  53139. * This represents a GPU particle system in Babylon
  53140. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53141. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53142. */
  53143. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53144. /**
  53145. * The layer mask we are rendering the particles through.
  53146. */
  53147. layerMask: number;
  53148. private _capacity;
  53149. private _activeCount;
  53150. private _currentActiveCount;
  53151. private _accumulatedCount;
  53152. private _renderEffect;
  53153. private _updateEffect;
  53154. private _buffer0;
  53155. private _buffer1;
  53156. private _spriteBuffer;
  53157. private _updateVAO;
  53158. private _renderVAO;
  53159. private _targetIndex;
  53160. private _sourceBuffer;
  53161. private _targetBuffer;
  53162. private _engine;
  53163. private _currentRenderId;
  53164. private _started;
  53165. private _stopped;
  53166. private _timeDelta;
  53167. private _randomTexture;
  53168. private _randomTexture2;
  53169. private _attributesStrideSize;
  53170. private _updateEffectOptions;
  53171. private _randomTextureSize;
  53172. private _actualFrame;
  53173. private readonly _rawTextureWidth;
  53174. /**
  53175. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53176. */
  53177. static readonly IsSupported: boolean;
  53178. /**
  53179. * An event triggered when the system is disposed.
  53180. */
  53181. onDisposeObservable: Observable<GPUParticleSystem>;
  53182. /**
  53183. * Gets the maximum number of particles active at the same time.
  53184. * @returns The max number of active particles.
  53185. */
  53186. getCapacity(): number;
  53187. /**
  53188. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53189. * to override the particles.
  53190. */
  53191. forceDepthWrite: boolean;
  53192. /**
  53193. * Gets or set the number of active particles
  53194. */
  53195. activeParticleCount: number;
  53196. private _preWarmDone;
  53197. /**
  53198. * Is this system ready to be used/rendered
  53199. * @return true if the system is ready
  53200. */
  53201. isReady(): boolean;
  53202. /**
  53203. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53204. * @returns True if it has been started, otherwise false.
  53205. */
  53206. isStarted(): boolean;
  53207. /**
  53208. * Starts the particle system and begins to emit
  53209. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53210. */
  53211. start(delay?: number): void;
  53212. /**
  53213. * Stops the particle system.
  53214. */
  53215. stop(): void;
  53216. /**
  53217. * Remove all active particles
  53218. */
  53219. reset(): void;
  53220. /**
  53221. * Returns the string "GPUParticleSystem"
  53222. * @returns a string containing the class name
  53223. */
  53224. getClassName(): string;
  53225. private _colorGradientsTexture;
  53226. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53227. /**
  53228. * Adds a new color gradient
  53229. * @param gradient defines the gradient to use (between 0 and 1)
  53230. * @param color1 defines the color to affect to the specified gradient
  53231. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53232. * @returns the current particle system
  53233. */
  53234. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53235. /**
  53236. * Remove a specific color gradient
  53237. * @param gradient defines the gradient to remove
  53238. * @returns the current particle system
  53239. */
  53240. removeColorGradient(gradient: number): GPUParticleSystem;
  53241. private _angularSpeedGradientsTexture;
  53242. private _sizeGradientsTexture;
  53243. private _velocityGradientsTexture;
  53244. private _limitVelocityGradientsTexture;
  53245. private _dragGradientsTexture;
  53246. private _addFactorGradient;
  53247. /**
  53248. * Adds a new size gradient
  53249. * @param gradient defines the gradient to use (between 0 and 1)
  53250. * @param factor defines the size factor to affect to the specified gradient
  53251. * @returns the current particle system
  53252. */
  53253. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53254. /**
  53255. * Remove a specific size gradient
  53256. * @param gradient defines the gradient to remove
  53257. * @returns the current particle system
  53258. */
  53259. removeSizeGradient(gradient: number): GPUParticleSystem;
  53260. /**
  53261. * Adds a new angular speed gradient
  53262. * @param gradient defines the gradient to use (between 0 and 1)
  53263. * @param factor defines the angular speed to affect to the specified gradient
  53264. * @returns the current particle system
  53265. */
  53266. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53267. /**
  53268. * Remove a specific angular speed gradient
  53269. * @param gradient defines the gradient to remove
  53270. * @returns the current particle system
  53271. */
  53272. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53273. /**
  53274. * Adds a new velocity gradient
  53275. * @param gradient defines the gradient to use (between 0 and 1)
  53276. * @param factor defines the velocity to affect to the specified gradient
  53277. * @returns the current particle system
  53278. */
  53279. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53280. /**
  53281. * Remove a specific velocity gradient
  53282. * @param gradient defines the gradient to remove
  53283. * @returns the current particle system
  53284. */
  53285. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53286. /**
  53287. * Adds a new limit velocity gradient
  53288. * @param gradient defines the gradient to use (between 0 and 1)
  53289. * @param factor defines the limit velocity value to affect to the specified gradient
  53290. * @returns the current particle system
  53291. */
  53292. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53293. /**
  53294. * Remove a specific limit velocity gradient
  53295. * @param gradient defines the gradient to remove
  53296. * @returns the current particle system
  53297. */
  53298. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53299. /**
  53300. * Adds a new drag gradient
  53301. * @param gradient defines the gradient to use (between 0 and 1)
  53302. * @param factor defines the drag value to affect to the specified gradient
  53303. * @returns the current particle system
  53304. */
  53305. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53306. /**
  53307. * Remove a specific drag gradient
  53308. * @param gradient defines the gradient to remove
  53309. * @returns the current particle system
  53310. */
  53311. removeDragGradient(gradient: number): GPUParticleSystem;
  53312. /**
  53313. * Not supported by GPUParticleSystem
  53314. * @param gradient defines the gradient to use (between 0 and 1)
  53315. * @param factor defines the emit rate value to affect to the specified gradient
  53316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53317. * @returns the current particle system
  53318. */
  53319. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53320. /**
  53321. * Not supported by GPUParticleSystem
  53322. * @param gradient defines the gradient to remove
  53323. * @returns the current particle system
  53324. */
  53325. removeEmitRateGradient(gradient: number): IParticleSystem;
  53326. /**
  53327. * Not supported by GPUParticleSystem
  53328. * @param gradient defines the gradient to use (between 0 and 1)
  53329. * @param factor defines the start size value to affect to the specified gradient
  53330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53331. * @returns the current particle system
  53332. */
  53333. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53334. /**
  53335. * Not supported by GPUParticleSystem
  53336. * @param gradient defines the gradient to remove
  53337. * @returns the current particle system
  53338. */
  53339. removeStartSizeGradient(gradient: number): IParticleSystem;
  53340. /**
  53341. * Not supported by GPUParticleSystem
  53342. * @param gradient defines the gradient to use (between 0 and 1)
  53343. * @param min defines the color remap minimal range
  53344. * @param max defines the color remap maximal range
  53345. * @returns the current particle system
  53346. */
  53347. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53348. /**
  53349. * Not supported by GPUParticleSystem
  53350. * @param gradient defines the gradient to remove
  53351. * @returns the current particle system
  53352. */
  53353. removeColorRemapGradient(): IParticleSystem;
  53354. /**
  53355. * Not supported by GPUParticleSystem
  53356. * @param gradient defines the gradient to use (between 0 and 1)
  53357. * @param min defines the alpha remap minimal range
  53358. * @param max defines the alpha remap maximal range
  53359. * @returns the current particle system
  53360. */
  53361. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53362. /**
  53363. * Not supported by GPUParticleSystem
  53364. * @param gradient defines the gradient to remove
  53365. * @returns the current particle system
  53366. */
  53367. removeAlphaRemapGradient(): IParticleSystem;
  53368. /**
  53369. * Not supported by GPUParticleSystem
  53370. * @param gradient defines the gradient to use (between 0 and 1)
  53371. * @param color defines the color to affect to the specified gradient
  53372. * @returns the current particle system
  53373. */
  53374. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53375. /**
  53376. * Not supported by GPUParticleSystem
  53377. * @param gradient defines the gradient to remove
  53378. * @returns the current particle system
  53379. */
  53380. removeRampGradient(): IParticleSystem;
  53381. /**
  53382. * Not supported by GPUParticleSystem
  53383. * @returns the list of ramp gradients
  53384. */
  53385. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53386. /**
  53387. * Not supported by GPUParticleSystem
  53388. * Gets or sets a boolean indicating that ramp gradients must be used
  53389. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53390. */
  53391. useRampGradients: boolean;
  53392. /**
  53393. * Not supported by GPUParticleSystem
  53394. * @param gradient defines the gradient to use (between 0 and 1)
  53395. * @param factor defines the life time factor to affect to the specified gradient
  53396. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53397. * @returns the current particle system
  53398. */
  53399. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53400. /**
  53401. * Not supported by GPUParticleSystem
  53402. * @param gradient defines the gradient to remove
  53403. * @returns the current particle system
  53404. */
  53405. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53406. /**
  53407. * Instantiates a GPU particle system.
  53408. * 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.
  53409. * @param name The name of the particle system
  53410. * @param options The options used to create the system
  53411. * @param scene The scene the particle system belongs to
  53412. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53413. */
  53414. constructor(name: string, options: Partial<{
  53415. capacity: number;
  53416. randomTextureSize: number;
  53417. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53418. protected _reset(): void;
  53419. private _createUpdateVAO;
  53420. private _createRenderVAO;
  53421. private _initialize;
  53422. /** @hidden */
  53423. _recreateUpdateEffect(): void;
  53424. /** @hidden */
  53425. _recreateRenderEffect(): void;
  53426. /**
  53427. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53428. * @param preWarm defines if we are in the pre-warmimg phase
  53429. */
  53430. animate(preWarm?: boolean): void;
  53431. private _createFactorGradientTexture;
  53432. private _createSizeGradientTexture;
  53433. private _createAngularSpeedGradientTexture;
  53434. private _createVelocityGradientTexture;
  53435. private _createLimitVelocityGradientTexture;
  53436. private _createDragGradientTexture;
  53437. private _createColorGradientTexture;
  53438. /**
  53439. * Renders the particle system in its current state
  53440. * @param preWarm defines if the system should only update the particles but not render them
  53441. * @returns the current number of particles
  53442. */
  53443. render(preWarm?: boolean): number;
  53444. /**
  53445. * Rebuilds the particle system
  53446. */
  53447. rebuild(): void;
  53448. private _releaseBuffers;
  53449. private _releaseVAOs;
  53450. /**
  53451. * Disposes the particle system and free the associated resources
  53452. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53453. */
  53454. dispose(disposeTexture?: boolean): void;
  53455. /**
  53456. * Clones the particle system.
  53457. * @param name The name of the cloned object
  53458. * @param newEmitter The new emitter to use
  53459. * @returns the cloned particle system
  53460. */
  53461. clone(name: string, newEmitter: any): GPUParticleSystem;
  53462. /**
  53463. * Serializes the particle system to a JSON object.
  53464. * @returns the JSON object
  53465. */
  53466. serialize(): any;
  53467. /**
  53468. * Parses a JSON object to create a GPU particle system.
  53469. * @param parsedParticleSystem The JSON object to parse
  53470. * @param scene The scene to create the particle system in
  53471. * @param rootUrl The root url to use to load external dependencies like texture
  53472. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53473. * @returns the parsed GPU particle system
  53474. */
  53475. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53476. }
  53477. }
  53478. declare module "babylonjs/Particles/particleSystemSet" {
  53479. import { Nullable } from "babylonjs/types";
  53480. import { Color3 } from "babylonjs/Maths/math";
  53481. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53483. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53484. import { Scene, IDisposable } from "babylonjs/scene";
  53485. /**
  53486. * Represents a set of particle systems working together to create a specific effect
  53487. */
  53488. export class ParticleSystemSet implements IDisposable {
  53489. private _emitterCreationOptions;
  53490. private _emitterNode;
  53491. /**
  53492. * Gets the particle system list
  53493. */
  53494. systems: IParticleSystem[];
  53495. /**
  53496. * Gets the emitter node used with this set
  53497. */
  53498. readonly emitterNode: Nullable<TransformNode>;
  53499. /**
  53500. * Creates a new emitter mesh as a sphere
  53501. * @param options defines the options used to create the sphere
  53502. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53503. * @param scene defines the hosting scene
  53504. */
  53505. setEmitterAsSphere(options: {
  53506. diameter: number;
  53507. segments: number;
  53508. color: Color3;
  53509. }, renderingGroupId: number, scene: Scene): void;
  53510. /**
  53511. * Starts all particle systems of the set
  53512. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53513. */
  53514. start(emitter?: AbstractMesh): void;
  53515. /**
  53516. * Release all associated resources
  53517. */
  53518. dispose(): void;
  53519. /**
  53520. * Serialize the set into a JSON compatible object
  53521. * @returns a JSON compatible representation of the set
  53522. */
  53523. serialize(): any;
  53524. /**
  53525. * Parse a new ParticleSystemSet from a serialized source
  53526. * @param data defines a JSON compatible representation of the set
  53527. * @param scene defines the hosting scene
  53528. * @param gpu defines if we want GPU particles or CPU particles
  53529. * @returns a new ParticleSystemSet
  53530. */
  53531. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53532. }
  53533. }
  53534. declare module "babylonjs/Particles/particleHelper" {
  53535. import { Nullable } from "babylonjs/types";
  53536. import { Scene } from "babylonjs/scene";
  53537. import { Vector3 } from "babylonjs/Maths/math";
  53538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53539. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53540. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53541. /**
  53542. * This class is made for on one-liner static method to help creating particle system set.
  53543. */
  53544. export class ParticleHelper {
  53545. /**
  53546. * Gets or sets base Assets URL
  53547. */
  53548. static BaseAssetsUrl: string;
  53549. /**
  53550. * Create a default particle system that you can tweak
  53551. * @param emitter defines the emitter to use
  53552. * @param capacity defines the system capacity (default is 500 particles)
  53553. * @param scene defines the hosting scene
  53554. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53555. * @returns the new Particle system
  53556. */
  53557. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53558. /**
  53559. * This is the main static method (one-liner) of this helper to create different particle systems
  53560. * @param type This string represents the type to the particle system to create
  53561. * @param scene The scene where the particle system should live
  53562. * @param gpu If the system will use gpu
  53563. * @returns the ParticleSystemSet created
  53564. */
  53565. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53566. /**
  53567. * Static function used to export a particle system to a ParticleSystemSet variable.
  53568. * Please note that the emitter shape is not exported
  53569. * @param systems defines the particle systems to export
  53570. * @returns the created particle system set
  53571. */
  53572. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53573. }
  53574. }
  53575. declare module "babylonjs/Particles/particleSystemComponent" {
  53576. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53577. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53578. import "babylonjs/Shaders/particles.vertex";
  53579. module "babylonjs/Engines/engine" {
  53580. interface Engine {
  53581. /**
  53582. * Create an effect to use with particle systems.
  53583. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53584. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53585. * @param uniformsNames defines a list of attribute names
  53586. * @param samplers defines an array of string used to represent textures
  53587. * @param defines defines the string containing the defines to use to compile the shaders
  53588. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53589. * @param onCompiled defines a function to call when the effect creation is successful
  53590. * @param onError defines a function to call when the effect creation has failed
  53591. * @returns the new Effect
  53592. */
  53593. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53594. }
  53595. }
  53596. module "babylonjs/Meshes/mesh" {
  53597. interface Mesh {
  53598. /**
  53599. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53600. * @returns an array of IParticleSystem
  53601. */
  53602. getEmittedParticleSystems(): IParticleSystem[];
  53603. /**
  53604. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53605. * @returns an array of IParticleSystem
  53606. */
  53607. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53608. }
  53609. }
  53610. /**
  53611. * @hidden
  53612. */
  53613. export var _IDoNeedToBeInTheBuild: number;
  53614. }
  53615. declare module "babylonjs/Particles/index" {
  53616. export * from "babylonjs/Particles/baseParticleSystem";
  53617. export * from "babylonjs/Particles/EmitterTypes/index";
  53618. export * from "babylonjs/Particles/gpuParticleSystem";
  53619. export * from "babylonjs/Particles/IParticleSystem";
  53620. export * from "babylonjs/Particles/particle";
  53621. export * from "babylonjs/Particles/particleHelper";
  53622. export * from "babylonjs/Particles/particleSystem";
  53623. export * from "babylonjs/Particles/particleSystemComponent";
  53624. export * from "babylonjs/Particles/particleSystemSet";
  53625. export * from "babylonjs/Particles/solidParticle";
  53626. export * from "babylonjs/Particles/solidParticleSystem";
  53627. export * from "babylonjs/Particles/subEmitter";
  53628. }
  53629. declare module "babylonjs/Physics/physicsEngineComponent" {
  53630. import { Nullable } from "babylonjs/types";
  53631. import { Observable, Observer } from "babylonjs/Misc/observable";
  53632. import { Vector3 } from "babylonjs/Maths/math";
  53633. import { Mesh } from "babylonjs/Meshes/mesh";
  53634. import { ISceneComponent } from "babylonjs/sceneComponent";
  53635. import { Scene } from "babylonjs/scene";
  53636. import { Node } from "babylonjs/node";
  53637. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53638. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53639. module "babylonjs/scene" {
  53640. interface Scene {
  53641. /** @hidden (Backing field) */
  53642. _physicsEngine: Nullable<IPhysicsEngine>;
  53643. /**
  53644. * Gets the current physics engine
  53645. * @returns a IPhysicsEngine or null if none attached
  53646. */
  53647. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53648. /**
  53649. * Enables physics to the current scene
  53650. * @param gravity defines the scene's gravity for the physics engine
  53651. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53652. * @return a boolean indicating if the physics engine was initialized
  53653. */
  53654. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53655. /**
  53656. * Disables and disposes the physics engine associated with the scene
  53657. */
  53658. disablePhysicsEngine(): void;
  53659. /**
  53660. * Gets a boolean indicating if there is an active physics engine
  53661. * @returns a boolean indicating if there is an active physics engine
  53662. */
  53663. isPhysicsEnabled(): boolean;
  53664. /**
  53665. * Deletes a physics compound impostor
  53666. * @param compound defines the compound to delete
  53667. */
  53668. deleteCompoundImpostor(compound: any): void;
  53669. /**
  53670. * An event triggered when physic simulation is about to be run
  53671. */
  53672. onBeforePhysicsObservable: Observable<Scene>;
  53673. /**
  53674. * An event triggered when physic simulation has been done
  53675. */
  53676. onAfterPhysicsObservable: Observable<Scene>;
  53677. }
  53678. }
  53679. module "babylonjs/Meshes/abstractMesh" {
  53680. interface AbstractMesh {
  53681. /** @hidden */
  53682. _physicsImpostor: Nullable<PhysicsImpostor>;
  53683. /**
  53684. * Gets or sets impostor used for physic simulation
  53685. * @see http://doc.babylonjs.com/features/physics_engine
  53686. */
  53687. physicsImpostor: Nullable<PhysicsImpostor>;
  53688. /**
  53689. * Gets the current physics impostor
  53690. * @see http://doc.babylonjs.com/features/physics_engine
  53691. * @returns a physics impostor or null
  53692. */
  53693. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53694. /** Apply a physic impulse to the mesh
  53695. * @param force defines the force to apply
  53696. * @param contactPoint defines where to apply the force
  53697. * @returns the current mesh
  53698. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53699. */
  53700. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53701. /**
  53702. * Creates a physic joint between two meshes
  53703. * @param otherMesh defines the other mesh to use
  53704. * @param pivot1 defines the pivot to use on this mesh
  53705. * @param pivot2 defines the pivot to use on the other mesh
  53706. * @param options defines additional options (can be plugin dependent)
  53707. * @returns the current mesh
  53708. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53709. */
  53710. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53711. /** @hidden */
  53712. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53713. }
  53714. }
  53715. /**
  53716. * Defines the physics engine scene component responsible to manage a physics engine
  53717. */
  53718. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53719. /**
  53720. * The component name helpful to identify the component in the list of scene components.
  53721. */
  53722. readonly name: string;
  53723. /**
  53724. * The scene the component belongs to.
  53725. */
  53726. scene: Scene;
  53727. /**
  53728. * Creates a new instance of the component for the given scene
  53729. * @param scene Defines the scene to register the component in
  53730. */
  53731. constructor(scene: Scene);
  53732. /**
  53733. * Registers the component in a given scene
  53734. */
  53735. register(): void;
  53736. /**
  53737. * Rebuilds the elements related to this component in case of
  53738. * context lost for instance.
  53739. */
  53740. rebuild(): void;
  53741. /**
  53742. * Disposes the component and the associated ressources
  53743. */
  53744. dispose(): void;
  53745. }
  53746. }
  53747. declare module "babylonjs/Physics/physicsHelper" {
  53748. import { Nullable } from "babylonjs/types";
  53749. import { Vector3 } from "babylonjs/Maths/math";
  53750. import { Mesh } from "babylonjs/Meshes/mesh";
  53751. import { Scene } from "babylonjs/scene";
  53752. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53753. /**
  53754. * A helper for physics simulations
  53755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53756. */
  53757. export class PhysicsHelper {
  53758. private _scene;
  53759. private _physicsEngine;
  53760. /**
  53761. * Initializes the Physics helper
  53762. * @param scene Babylon.js scene
  53763. */
  53764. constructor(scene: Scene);
  53765. /**
  53766. * Applies a radial explosion impulse
  53767. * @param origin the origin of the explosion
  53768. * @param radiusOrEventOptions the radius or the options of radial explosion
  53769. * @param strength the explosion strength
  53770. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53771. * @returns A physics radial explosion event, or null
  53772. */
  53773. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53774. /**
  53775. * Applies a radial explosion force
  53776. * @param origin the origin of the explosion
  53777. * @param radiusOrEventOptions the radius or the options of radial explosion
  53778. * @param strength the explosion strength
  53779. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53780. * @returns A physics radial explosion event, or null
  53781. */
  53782. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53783. /**
  53784. * Creates a gravitational field
  53785. * @param origin the origin of the explosion
  53786. * @param radiusOrEventOptions the radius or the options of radial explosion
  53787. * @param strength the explosion strength
  53788. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53789. * @returns A physics gravitational field event, or null
  53790. */
  53791. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53792. /**
  53793. * Creates a physics updraft event
  53794. * @param origin the origin of the updraft
  53795. * @param radiusOrEventOptions the radius or the options of the updraft
  53796. * @param strength the strength of the updraft
  53797. * @param height the height of the updraft
  53798. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53799. * @returns A physics updraft event, or null
  53800. */
  53801. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53802. /**
  53803. * Creates a physics vortex event
  53804. * @param origin the of the vortex
  53805. * @param radiusOrEventOptions the radius or the options of the vortex
  53806. * @param strength the strength of the vortex
  53807. * @param height the height of the vortex
  53808. * @returns a Physics vortex event, or null
  53809. * A physics vortex event or null
  53810. */
  53811. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53812. }
  53813. /**
  53814. * Represents a physics radial explosion event
  53815. */
  53816. class PhysicsRadialExplosionEvent {
  53817. private _scene;
  53818. private _options;
  53819. private _sphere;
  53820. private _dataFetched;
  53821. /**
  53822. * Initializes a radial explosioin event
  53823. * @param _scene BabylonJS scene
  53824. * @param _options The options for the vortex event
  53825. */
  53826. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53827. /**
  53828. * Returns the data related to the radial explosion event (sphere).
  53829. * @returns The radial explosion event data
  53830. */
  53831. getData(): PhysicsRadialExplosionEventData;
  53832. /**
  53833. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53834. * @param impostor A physics imposter
  53835. * @param origin the origin of the explosion
  53836. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53837. */
  53838. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53839. /**
  53840. * Triggers affecterd impostors callbacks
  53841. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53842. */
  53843. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53844. /**
  53845. * Disposes the sphere.
  53846. * @param force Specifies if the sphere should be disposed by force
  53847. */
  53848. dispose(force?: boolean): void;
  53849. /*** Helpers ***/
  53850. private _prepareSphere;
  53851. private _intersectsWithSphere;
  53852. }
  53853. /**
  53854. * Represents a gravitational field event
  53855. */
  53856. class PhysicsGravitationalFieldEvent {
  53857. private _physicsHelper;
  53858. private _scene;
  53859. private _origin;
  53860. private _options;
  53861. private _tickCallback;
  53862. private _sphere;
  53863. private _dataFetched;
  53864. /**
  53865. * Initializes the physics gravitational field event
  53866. * @param _physicsHelper A physics helper
  53867. * @param _scene BabylonJS scene
  53868. * @param _origin The origin position of the gravitational field event
  53869. * @param _options The options for the vortex event
  53870. */
  53871. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  53872. /**
  53873. * Returns the data related to the gravitational field event (sphere).
  53874. * @returns A gravitational field event
  53875. */
  53876. getData(): PhysicsGravitationalFieldEventData;
  53877. /**
  53878. * Enables the gravitational field.
  53879. */
  53880. enable(): void;
  53881. /**
  53882. * Disables the gravitational field.
  53883. */
  53884. disable(): void;
  53885. /**
  53886. * Disposes the sphere.
  53887. * @param force The force to dispose from the gravitational field event
  53888. */
  53889. dispose(force?: boolean): void;
  53890. private _tick;
  53891. }
  53892. /**
  53893. * Represents a physics updraft event
  53894. */
  53895. class PhysicsUpdraftEvent {
  53896. private _scene;
  53897. private _origin;
  53898. private _options;
  53899. private _physicsEngine;
  53900. private _originTop;
  53901. private _originDirection;
  53902. private _tickCallback;
  53903. private _cylinder;
  53904. private _cylinderPosition;
  53905. private _dataFetched;
  53906. /**
  53907. * Initializes the physics updraft event
  53908. * @param _scene BabylonJS scene
  53909. * @param _origin The origin position of the updraft
  53910. * @param _options The options for the updraft event
  53911. */
  53912. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53913. /**
  53914. * Returns the data related to the updraft event (cylinder).
  53915. * @returns A physics updraft event
  53916. */
  53917. getData(): PhysicsUpdraftEventData;
  53918. /**
  53919. * Enables the updraft.
  53920. */
  53921. enable(): void;
  53922. /**
  53923. * Disables the updraft.
  53924. */
  53925. disable(): void;
  53926. /**
  53927. * Disposes the cylinder.
  53928. * @param force Specifies if the updraft should be disposed by force
  53929. */
  53930. dispose(force?: boolean): void;
  53931. private getImpostorHitData;
  53932. private _tick;
  53933. /*** Helpers ***/
  53934. private _prepareCylinder;
  53935. private _intersectsWithCylinder;
  53936. }
  53937. /**
  53938. * Represents a physics vortex event
  53939. */
  53940. class PhysicsVortexEvent {
  53941. private _scene;
  53942. private _origin;
  53943. private _options;
  53944. private _physicsEngine;
  53945. private _originTop;
  53946. private _tickCallback;
  53947. private _cylinder;
  53948. private _cylinderPosition;
  53949. private _dataFetched;
  53950. /**
  53951. * Initializes the physics vortex event
  53952. * @param _scene The BabylonJS scene
  53953. * @param _origin The origin position of the vortex
  53954. * @param _options The options for the vortex event
  53955. */
  53956. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53957. /**
  53958. * Returns the data related to the vortex event (cylinder).
  53959. * @returns The physics vortex event data
  53960. */
  53961. getData(): PhysicsVortexEventData;
  53962. /**
  53963. * Enables the vortex.
  53964. */
  53965. enable(): void;
  53966. /**
  53967. * Disables the cortex.
  53968. */
  53969. disable(): void;
  53970. /**
  53971. * Disposes the sphere.
  53972. * @param force
  53973. */
  53974. dispose(force?: boolean): void;
  53975. private getImpostorHitData;
  53976. private _tick;
  53977. /*** Helpers ***/
  53978. private _prepareCylinder;
  53979. private _intersectsWithCylinder;
  53980. }
  53981. /**
  53982. * Options fot the radial explosion event
  53983. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53984. */
  53985. export class PhysicsRadialExplosionEventOptions {
  53986. /**
  53987. * The radius of the sphere for the radial explosion.
  53988. */
  53989. radius: number;
  53990. /**
  53991. * The strenth of the explosion.
  53992. */
  53993. strength: number;
  53994. /**
  53995. * The strenght of the force in correspondence to the distance of the affected object
  53996. */
  53997. falloff: PhysicsRadialImpulseFalloff;
  53998. /**
  53999. * Sphere options for the radial explosion.
  54000. */
  54001. sphere: {
  54002. segments: number;
  54003. diameter: number;
  54004. };
  54005. /**
  54006. * Sphere options for the radial explosion.
  54007. */
  54008. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54009. }
  54010. /**
  54011. * Options fot the updraft event
  54012. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54013. */
  54014. export class PhysicsUpdraftEventOptions {
  54015. /**
  54016. * The radius of the cylinder for the vortex
  54017. */
  54018. radius: number;
  54019. /**
  54020. * The strenth of the updraft.
  54021. */
  54022. strength: number;
  54023. /**
  54024. * The height of the cylinder for the updraft.
  54025. */
  54026. height: number;
  54027. /**
  54028. * The mode for the the updraft.
  54029. */
  54030. updraftMode: PhysicsUpdraftMode;
  54031. }
  54032. /**
  54033. * Options fot the vortex event
  54034. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54035. */
  54036. export class PhysicsVortexEventOptions {
  54037. /**
  54038. * The radius of the cylinder for the vortex
  54039. */
  54040. radius: number;
  54041. /**
  54042. * The strenth of the vortex.
  54043. */
  54044. strength: number;
  54045. /**
  54046. * The height of the cylinder for the vortex.
  54047. */
  54048. height: number;
  54049. /**
  54050. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54051. */
  54052. centripetalForceThreshold: number;
  54053. /**
  54054. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54055. */
  54056. centripetalForceMultiplier: number;
  54057. /**
  54058. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54059. */
  54060. centrifugalForceMultiplier: number;
  54061. /**
  54062. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54063. */
  54064. updraftForceMultiplier: number;
  54065. }
  54066. /**
  54067. * The strenght of the force in correspondence to the distance of the affected object
  54068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54069. */
  54070. export enum PhysicsRadialImpulseFalloff {
  54071. /** Defines that impulse is constant in strength across it's whole radius */
  54072. Constant = 0,
  54073. /** Defines that impulse gets weaker if it's further from the origin */
  54074. Linear = 1
  54075. }
  54076. /**
  54077. * The strength of the force in correspondence to the distance of the affected object
  54078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54079. */
  54080. export enum PhysicsUpdraftMode {
  54081. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54082. Center = 0,
  54083. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54084. Perpendicular = 1
  54085. }
  54086. /**
  54087. * Interface for a physics hit data
  54088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54089. */
  54090. export interface PhysicsHitData {
  54091. /**
  54092. * The force applied at the contact point
  54093. */
  54094. force: Vector3;
  54095. /**
  54096. * The contact point
  54097. */
  54098. contactPoint: Vector3;
  54099. /**
  54100. * The distance from the origin to the contact point
  54101. */
  54102. distanceFromOrigin: number;
  54103. }
  54104. /**
  54105. * Interface for radial explosion event data
  54106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54107. */
  54108. export interface PhysicsRadialExplosionEventData {
  54109. /**
  54110. * A sphere used for the radial explosion event
  54111. */
  54112. sphere: Mesh;
  54113. }
  54114. /**
  54115. * Interface for gravitational field event data
  54116. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54117. */
  54118. export interface PhysicsGravitationalFieldEventData {
  54119. /**
  54120. * A sphere mesh used for the gravitational field event
  54121. */
  54122. sphere: Mesh;
  54123. }
  54124. /**
  54125. * Interface for updraft event data
  54126. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54127. */
  54128. export interface PhysicsUpdraftEventData {
  54129. /**
  54130. * A cylinder used for the updraft event
  54131. */
  54132. cylinder: Mesh;
  54133. }
  54134. /**
  54135. * Interface for vortex event data
  54136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54137. */
  54138. export interface PhysicsVortexEventData {
  54139. /**
  54140. * A cylinder used for the vortex event
  54141. */
  54142. cylinder: Mesh;
  54143. }
  54144. /**
  54145. * Interface for an affected physics impostor
  54146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54147. */
  54148. export interface PhysicsAffectedImpostorWithData {
  54149. /**
  54150. * The impostor affected by the effect
  54151. */
  54152. impostor: PhysicsImpostor;
  54153. /**
  54154. * The data about the hit/horce from the explosion
  54155. */
  54156. hitData: PhysicsHitData;
  54157. }
  54158. }
  54159. declare module "babylonjs/Physics/Plugins/index" {
  54160. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54161. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54162. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54163. }
  54164. declare module "babylonjs/Physics/index" {
  54165. export * from "babylonjs/Physics/IPhysicsEngine";
  54166. export * from "babylonjs/Physics/physicsEngine";
  54167. export * from "babylonjs/Physics/physicsEngineComponent";
  54168. export * from "babylonjs/Physics/physicsHelper";
  54169. export * from "babylonjs/Physics/physicsImpostor";
  54170. export * from "babylonjs/Physics/physicsJoint";
  54171. export * from "babylonjs/Physics/Plugins/index";
  54172. }
  54173. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54174. /** @hidden */
  54175. export var blackAndWhitePixelShader: {
  54176. name: string;
  54177. shader: string;
  54178. };
  54179. }
  54180. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54181. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54182. import { Camera } from "babylonjs/Cameras/camera";
  54183. import { Engine } from "babylonjs/Engines/engine";
  54184. import "babylonjs/Shaders/blackAndWhite.fragment";
  54185. /**
  54186. * Post process used to render in black and white
  54187. */
  54188. export class BlackAndWhitePostProcess extends PostProcess {
  54189. /**
  54190. * Linear about to convert he result to black and white (default: 1)
  54191. */
  54192. degree: number;
  54193. /**
  54194. * Creates a black and white post process
  54195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54196. * @param name The name of the effect.
  54197. * @param options The required width/height ratio to downsize to before computing the render pass.
  54198. * @param camera The camera to apply the render pass to.
  54199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54200. * @param engine The engine which the post process will be applied. (default: current engine)
  54201. * @param reusable If the post process can be reused on the same frame. (default: false)
  54202. */
  54203. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54204. }
  54205. }
  54206. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54207. import { Nullable } from "babylonjs/types";
  54208. import { Camera } from "babylonjs/Cameras/camera";
  54209. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54210. import { Engine } from "babylonjs/Engines/engine";
  54211. /**
  54212. * This represents a set of one or more post processes in Babylon.
  54213. * A post process can be used to apply a shader to a texture after it is rendered.
  54214. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54215. */
  54216. export class PostProcessRenderEffect {
  54217. private _postProcesses;
  54218. private _getPostProcesses;
  54219. private _singleInstance;
  54220. private _cameras;
  54221. private _indicesForCamera;
  54222. /**
  54223. * Name of the effect
  54224. * @hidden
  54225. */
  54226. _name: string;
  54227. /**
  54228. * Instantiates a post process render effect.
  54229. * A post process can be used to apply a shader to a texture after it is rendered.
  54230. * @param engine The engine the effect is tied to
  54231. * @param name The name of the effect
  54232. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54233. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54234. */
  54235. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54236. /**
  54237. * Checks if all the post processes in the effect are supported.
  54238. */
  54239. readonly isSupported: boolean;
  54240. /**
  54241. * Updates the current state of the effect
  54242. * @hidden
  54243. */
  54244. _update(): void;
  54245. /**
  54246. * Attaches the effect on cameras
  54247. * @param cameras The camera to attach to.
  54248. * @hidden
  54249. */
  54250. _attachCameras(cameras: Camera): void;
  54251. /**
  54252. * Attaches the effect on cameras
  54253. * @param cameras The camera to attach to.
  54254. * @hidden
  54255. */
  54256. _attachCameras(cameras: Camera[]): void;
  54257. /**
  54258. * Detatches the effect on cameras
  54259. * @param cameras The camera to detatch from.
  54260. * @hidden
  54261. */
  54262. _detachCameras(cameras: Camera): void;
  54263. /**
  54264. * Detatches the effect on cameras
  54265. * @param cameras The camera to detatch from.
  54266. * @hidden
  54267. */
  54268. _detachCameras(cameras: Camera[]): void;
  54269. /**
  54270. * Enables the effect on given cameras
  54271. * @param cameras The camera to enable.
  54272. * @hidden
  54273. */
  54274. _enable(cameras: Camera): void;
  54275. /**
  54276. * Enables the effect on given cameras
  54277. * @param cameras The camera to enable.
  54278. * @hidden
  54279. */
  54280. _enable(cameras: Nullable<Camera[]>): void;
  54281. /**
  54282. * Disables the effect on the given cameras
  54283. * @param cameras The camera to disable.
  54284. * @hidden
  54285. */
  54286. _disable(cameras: Camera): void;
  54287. /**
  54288. * Disables the effect on the given cameras
  54289. * @param cameras The camera to disable.
  54290. * @hidden
  54291. */
  54292. _disable(cameras: Nullable<Camera[]>): void;
  54293. /**
  54294. * Gets a list of the post processes contained in the effect.
  54295. * @param camera The camera to get the post processes on.
  54296. * @returns The list of the post processes in the effect.
  54297. */
  54298. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54299. }
  54300. }
  54301. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54302. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54303. /** @hidden */
  54304. export var extractHighlightsPixelShader: {
  54305. name: string;
  54306. shader: string;
  54307. };
  54308. }
  54309. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54310. import { Nullable } from "babylonjs/types";
  54311. import { Camera } from "babylonjs/Cameras/camera";
  54312. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54313. import { Engine } from "babylonjs/Engines/engine";
  54314. import "babylonjs/Shaders/extractHighlights.fragment";
  54315. /**
  54316. * 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.
  54317. */
  54318. export class ExtractHighlightsPostProcess extends PostProcess {
  54319. /**
  54320. * The luminance threshold, pixels below this value will be set to black.
  54321. */
  54322. threshold: number;
  54323. /** @hidden */
  54324. _exposure: number;
  54325. /**
  54326. * Post process which has the input texture to be used when performing highlight extraction
  54327. * @hidden
  54328. */
  54329. _inputPostProcess: Nullable<PostProcess>;
  54330. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54331. }
  54332. }
  54333. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54334. /** @hidden */
  54335. export var bloomMergePixelShader: {
  54336. name: string;
  54337. shader: string;
  54338. };
  54339. }
  54340. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54341. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54342. import { Nullable } from "babylonjs/types";
  54343. import { Engine } from "babylonjs/Engines/engine";
  54344. import { Camera } from "babylonjs/Cameras/camera";
  54345. import "babylonjs/Shaders/bloomMerge.fragment";
  54346. /**
  54347. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54348. */
  54349. export class BloomMergePostProcess extends PostProcess {
  54350. /** Weight of the bloom to be added to the original input. */
  54351. weight: number;
  54352. /**
  54353. * Creates a new instance of @see BloomMergePostProcess
  54354. * @param name The name of the effect.
  54355. * @param originalFromInput Post process which's input will be used for the merge.
  54356. * @param blurred Blurred highlights post process which's output will be used.
  54357. * @param weight Weight of the bloom to be added to the original input.
  54358. * @param options The required width/height ratio to downsize to before computing the render pass.
  54359. * @param camera The camera to apply the render pass to.
  54360. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54361. * @param engine The engine which the post process will be applied. (default: current engine)
  54362. * @param reusable If the post process can be reused on the same frame. (default: false)
  54363. * @param textureType Type of textures used when performing the post process. (default: 0)
  54364. * @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)
  54365. */
  54366. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54367. /** Weight of the bloom to be added to the original input. */
  54368. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54369. }
  54370. }
  54371. declare module "babylonjs/PostProcesses/bloomEffect" {
  54372. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54373. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54374. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54375. import { Camera } from "babylonjs/Cameras/camera";
  54376. import { Scene } from "babylonjs/scene";
  54377. /**
  54378. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54379. */
  54380. export class BloomEffect extends PostProcessRenderEffect {
  54381. private bloomScale;
  54382. /**
  54383. * @hidden Internal
  54384. */
  54385. _effects: Array<PostProcess>;
  54386. /**
  54387. * @hidden Internal
  54388. */
  54389. _downscale: ExtractHighlightsPostProcess;
  54390. private _blurX;
  54391. private _blurY;
  54392. private _merge;
  54393. /**
  54394. * The luminance threshold to find bright areas of the image to bloom.
  54395. */
  54396. threshold: number;
  54397. /**
  54398. * The strength of the bloom.
  54399. */
  54400. weight: number;
  54401. /**
  54402. * Specifies the size of the bloom blur kernel, relative to the final output size
  54403. */
  54404. kernel: number;
  54405. /**
  54406. * Creates a new instance of @see BloomEffect
  54407. * @param scene The scene the effect belongs to.
  54408. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54409. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54410. * @param bloomWeight The the strength of bloom.
  54411. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54412. * @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)
  54413. */
  54414. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54415. /**
  54416. * Disposes each of the internal effects for a given camera.
  54417. * @param camera The camera to dispose the effect on.
  54418. */
  54419. disposeEffects(camera: Camera): void;
  54420. /**
  54421. * @hidden Internal
  54422. */
  54423. _updateEffects(): void;
  54424. /**
  54425. * Internal
  54426. * @returns if all the contained post processes are ready.
  54427. * @hidden
  54428. */
  54429. _isReady(): boolean;
  54430. }
  54431. }
  54432. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54433. /** @hidden */
  54434. export var chromaticAberrationPixelShader: {
  54435. name: string;
  54436. shader: string;
  54437. };
  54438. }
  54439. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54440. import { Vector2 } from "babylonjs/Maths/math";
  54441. import { Nullable } from "babylonjs/types";
  54442. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54443. import { Camera } from "babylonjs/Cameras/camera";
  54444. import { Engine } from "babylonjs/Engines/engine";
  54445. import "babylonjs/Shaders/chromaticAberration.fragment";
  54446. /**
  54447. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54448. */
  54449. export class ChromaticAberrationPostProcess extends PostProcess {
  54450. /**
  54451. * The amount of seperation of rgb channels (default: 30)
  54452. */
  54453. aberrationAmount: number;
  54454. /**
  54455. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54456. */
  54457. radialIntensity: number;
  54458. /**
  54459. * 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))
  54460. */
  54461. direction: Vector2;
  54462. /**
  54463. * 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))
  54464. */
  54465. centerPosition: Vector2;
  54466. /**
  54467. * Creates a new instance ChromaticAberrationPostProcess
  54468. * @param name The name of the effect.
  54469. * @param screenWidth The width of the screen to apply the effect on.
  54470. * @param screenHeight The height of the screen to apply the effect on.
  54471. * @param options The required width/height ratio to downsize to before computing the render pass.
  54472. * @param camera The camera to apply the render pass to.
  54473. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54474. * @param engine The engine which the post process will be applied. (default: current engine)
  54475. * @param reusable If the post process can be reused on the same frame. (default: false)
  54476. * @param textureType Type of textures used when performing the post process. (default: 0)
  54477. * @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)
  54478. */
  54479. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54480. }
  54481. }
  54482. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54483. /** @hidden */
  54484. export var circleOfConfusionPixelShader: {
  54485. name: string;
  54486. shader: string;
  54487. };
  54488. }
  54489. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54490. import { Nullable } from "babylonjs/types";
  54491. import { Engine } from "babylonjs/Engines/engine";
  54492. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54493. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54494. import { Camera } from "babylonjs/Cameras/camera";
  54495. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54496. /**
  54497. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54498. */
  54499. export class CircleOfConfusionPostProcess extends PostProcess {
  54500. /**
  54501. * 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.
  54502. */
  54503. lensSize: number;
  54504. /**
  54505. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54506. */
  54507. fStop: number;
  54508. /**
  54509. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54510. */
  54511. focusDistance: number;
  54512. /**
  54513. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54514. */
  54515. focalLength: number;
  54516. private _depthTexture;
  54517. /**
  54518. * Creates a new instance CircleOfConfusionPostProcess
  54519. * @param name The name of the effect.
  54520. * @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.
  54521. * @param options The required width/height ratio to downsize to before computing the render pass.
  54522. * @param camera The camera to apply the render pass to.
  54523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54524. * @param engine The engine which the post process will be applied. (default: current engine)
  54525. * @param reusable If the post process can be reused on the same frame. (default: false)
  54526. * @param textureType Type of textures used when performing the post process. (default: 0)
  54527. * @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)
  54528. */
  54529. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54530. /**
  54531. * 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.
  54532. */
  54533. depthTexture: RenderTargetTexture;
  54534. }
  54535. }
  54536. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54537. /** @hidden */
  54538. export var colorCorrectionPixelShader: {
  54539. name: string;
  54540. shader: string;
  54541. };
  54542. }
  54543. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54544. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54545. import { Engine } from "babylonjs/Engines/engine";
  54546. import { Camera } from "babylonjs/Cameras/camera";
  54547. import "babylonjs/Shaders/colorCorrection.fragment";
  54548. /**
  54549. *
  54550. * This post-process allows the modification of rendered colors by using
  54551. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54552. *
  54553. * The object needs to be provided an url to a texture containing the color
  54554. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54555. * Use an image editing software to tweak the LUT to match your needs.
  54556. *
  54557. * For an example of a color LUT, see here:
  54558. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54559. * For explanations on color grading, see here:
  54560. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54561. *
  54562. */
  54563. export class ColorCorrectionPostProcess extends PostProcess {
  54564. private _colorTableTexture;
  54565. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54566. }
  54567. }
  54568. declare module "babylonjs/Shaders/convolution.fragment" {
  54569. /** @hidden */
  54570. export var convolutionPixelShader: {
  54571. name: string;
  54572. shader: string;
  54573. };
  54574. }
  54575. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54576. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54577. import { Nullable } from "babylonjs/types";
  54578. import { Camera } from "babylonjs/Cameras/camera";
  54579. import { Engine } from "babylonjs/Engines/engine";
  54580. import "babylonjs/Shaders/convolution.fragment";
  54581. /**
  54582. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54583. * input texture to perform effects such as edge detection or sharpening
  54584. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54585. */
  54586. export class ConvolutionPostProcess extends PostProcess {
  54587. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54588. kernel: number[];
  54589. /**
  54590. * Creates a new instance ConvolutionPostProcess
  54591. * @param name The name of the effect.
  54592. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54593. * @param options The required width/height ratio to downsize to before computing the render pass.
  54594. * @param camera The camera to apply the render pass to.
  54595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54596. * @param engine The engine which the post process will be applied. (default: current engine)
  54597. * @param reusable If the post process can be reused on the same frame. (default: false)
  54598. * @param textureType Type of textures used when performing the post process. (default: 0)
  54599. */
  54600. constructor(name: string,
  54601. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54602. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54603. /**
  54604. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54605. */
  54606. static EdgeDetect0Kernel: number[];
  54607. /**
  54608. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54609. */
  54610. static EdgeDetect1Kernel: number[];
  54611. /**
  54612. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54613. */
  54614. static EdgeDetect2Kernel: number[];
  54615. /**
  54616. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54617. */
  54618. static SharpenKernel: number[];
  54619. /**
  54620. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54621. */
  54622. static EmbossKernel: number[];
  54623. /**
  54624. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54625. */
  54626. static GaussianKernel: number[];
  54627. }
  54628. }
  54629. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54630. import { Nullable } from "babylonjs/types";
  54631. import { Vector2 } from "babylonjs/Maths/math";
  54632. import { Camera } from "babylonjs/Cameras/camera";
  54633. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54634. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54635. import { Engine } from "babylonjs/Engines/engine";
  54636. import { Scene } from "babylonjs/scene";
  54637. /**
  54638. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54639. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54640. * based on samples that have a large difference in distance than the center pixel.
  54641. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54642. */
  54643. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54644. direction: Vector2;
  54645. /**
  54646. * Creates a new instance CircleOfConfusionPostProcess
  54647. * @param name The name of the effect.
  54648. * @param scene The scene the effect belongs to.
  54649. * @param direction The direction the blur should be applied.
  54650. * @param kernel The size of the kernel used to blur.
  54651. * @param options The required width/height ratio to downsize to before computing the render pass.
  54652. * @param camera The camera to apply the render pass to.
  54653. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54654. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54655. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54656. * @param engine The engine which the post process will be applied. (default: current engine)
  54657. * @param reusable If the post process can be reused on the same frame. (default: false)
  54658. * @param textureType Type of textures used when performing the post process. (default: 0)
  54659. * @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)
  54660. */
  54661. 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);
  54662. }
  54663. }
  54664. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54665. /** @hidden */
  54666. export var depthOfFieldMergePixelShader: {
  54667. name: string;
  54668. shader: string;
  54669. };
  54670. }
  54671. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54672. import { Nullable } from "babylonjs/types";
  54673. import { Camera } from "babylonjs/Cameras/camera";
  54674. import { Effect } from "babylonjs/Materials/effect";
  54675. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54676. import { Engine } from "babylonjs/Engines/engine";
  54677. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54678. /**
  54679. * Options to be set when merging outputs from the default pipeline.
  54680. */
  54681. export class DepthOfFieldMergePostProcessOptions {
  54682. /**
  54683. * The original image to merge on top of
  54684. */
  54685. originalFromInput: PostProcess;
  54686. /**
  54687. * Parameters to perform the merge of the depth of field effect
  54688. */
  54689. depthOfField?: {
  54690. circleOfConfusion: PostProcess;
  54691. blurSteps: Array<PostProcess>;
  54692. };
  54693. /**
  54694. * Parameters to perform the merge of bloom effect
  54695. */
  54696. bloom?: {
  54697. blurred: PostProcess;
  54698. weight: number;
  54699. };
  54700. }
  54701. /**
  54702. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54703. */
  54704. export class DepthOfFieldMergePostProcess extends PostProcess {
  54705. private blurSteps;
  54706. /**
  54707. * Creates a new instance of DepthOfFieldMergePostProcess
  54708. * @param name The name of the effect.
  54709. * @param originalFromInput Post process which's input will be used for the merge.
  54710. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54711. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54712. * @param options The required width/height ratio to downsize to before computing the render pass.
  54713. * @param camera The camera to apply the render pass to.
  54714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54715. * @param engine The engine which the post process will be applied. (default: current engine)
  54716. * @param reusable If the post process can be reused on the same frame. (default: false)
  54717. * @param textureType Type of textures used when performing the post process. (default: 0)
  54718. * @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)
  54719. */
  54720. 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);
  54721. /**
  54722. * Updates the effect with the current post process compile time values and recompiles the shader.
  54723. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54724. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54725. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54726. * @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
  54727. * @param onCompiled Called when the shader has been compiled.
  54728. * @param onError Called if there is an error when compiling a shader.
  54729. */
  54730. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54731. }
  54732. }
  54733. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54734. import { Nullable } from "babylonjs/types";
  54735. import { Camera } from "babylonjs/Cameras/camera";
  54736. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54737. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54738. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54739. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54740. import { Scene } from "babylonjs/scene";
  54741. /**
  54742. * Specifies the level of max blur that should be applied when using the depth of field effect
  54743. */
  54744. export enum DepthOfFieldEffectBlurLevel {
  54745. /**
  54746. * Subtle blur
  54747. */
  54748. Low = 0,
  54749. /**
  54750. * Medium blur
  54751. */
  54752. Medium = 1,
  54753. /**
  54754. * Large blur
  54755. */
  54756. High = 2
  54757. }
  54758. /**
  54759. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54760. */
  54761. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54762. private _circleOfConfusion;
  54763. /**
  54764. * @hidden Internal, blurs from high to low
  54765. */
  54766. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54767. private _depthOfFieldBlurY;
  54768. private _dofMerge;
  54769. /**
  54770. * @hidden Internal post processes in depth of field effect
  54771. */
  54772. _effects: Array<PostProcess>;
  54773. /**
  54774. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54775. */
  54776. focalLength: number;
  54777. /**
  54778. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54779. */
  54780. fStop: number;
  54781. /**
  54782. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54783. */
  54784. focusDistance: number;
  54785. /**
  54786. * 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.
  54787. */
  54788. lensSize: number;
  54789. /**
  54790. * Creates a new instance DepthOfFieldEffect
  54791. * @param scene The scene the effect belongs to.
  54792. * @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.
  54793. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54794. * @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)
  54795. */
  54796. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54797. /**
  54798. * 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.
  54799. */
  54800. depthTexture: RenderTargetTexture;
  54801. /**
  54802. * Disposes each of the internal effects for a given camera.
  54803. * @param camera The camera to dispose the effect on.
  54804. */
  54805. disposeEffects(camera: Camera): void;
  54806. /**
  54807. * @hidden Internal
  54808. */
  54809. _updateEffects(): void;
  54810. /**
  54811. * Internal
  54812. * @returns if all the contained post processes are ready.
  54813. * @hidden
  54814. */
  54815. _isReady(): boolean;
  54816. }
  54817. }
  54818. declare module "babylonjs/Shaders/displayPass.fragment" {
  54819. /** @hidden */
  54820. export var displayPassPixelShader: {
  54821. name: string;
  54822. shader: string;
  54823. };
  54824. }
  54825. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54826. import { Nullable } from "babylonjs/types";
  54827. import { Camera } from "babylonjs/Cameras/camera";
  54828. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54829. import { Engine } from "babylonjs/Engines/engine";
  54830. import "babylonjs/Shaders/displayPass.fragment";
  54831. /**
  54832. * DisplayPassPostProcess which produces an output the same as it's input
  54833. */
  54834. export class DisplayPassPostProcess extends PostProcess {
  54835. /**
  54836. * Creates the DisplayPassPostProcess
  54837. * @param name The name of the effect.
  54838. * @param options The required width/height ratio to downsize to before computing the render pass.
  54839. * @param camera The camera to apply the render pass to.
  54840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54841. * @param engine The engine which the post process will be applied. (default: current engine)
  54842. * @param reusable If the post process can be reused on the same frame. (default: false)
  54843. */
  54844. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54845. }
  54846. }
  54847. declare module "babylonjs/Shaders/filter.fragment" {
  54848. /** @hidden */
  54849. export var filterPixelShader: {
  54850. name: string;
  54851. shader: string;
  54852. };
  54853. }
  54854. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54855. import { Nullable } from "babylonjs/types";
  54856. import { Matrix } from "babylonjs/Maths/math";
  54857. import { Camera } from "babylonjs/Cameras/camera";
  54858. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54859. import { Engine } from "babylonjs/Engines/engine";
  54860. import "babylonjs/Shaders/filter.fragment";
  54861. /**
  54862. * Applies a kernel filter to the image
  54863. */
  54864. export class FilterPostProcess extends PostProcess {
  54865. /** The matrix to be applied to the image */
  54866. kernelMatrix: Matrix;
  54867. /**
  54868. *
  54869. * @param name The name of the effect.
  54870. * @param kernelMatrix The matrix to be applied to the image
  54871. * @param options The required width/height ratio to downsize to before computing the render pass.
  54872. * @param camera The camera to apply the render pass to.
  54873. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54874. * @param engine The engine which the post process will be applied. (default: current engine)
  54875. * @param reusable If the post process can be reused on the same frame. (default: false)
  54876. */
  54877. constructor(name: string,
  54878. /** The matrix to be applied to the image */
  54879. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54880. }
  54881. }
  54882. declare module "babylonjs/Shaders/fxaa.fragment" {
  54883. /** @hidden */
  54884. export var fxaaPixelShader: {
  54885. name: string;
  54886. shader: string;
  54887. };
  54888. }
  54889. declare module "babylonjs/Shaders/fxaa.vertex" {
  54890. /** @hidden */
  54891. export var fxaaVertexShader: {
  54892. name: string;
  54893. shader: string;
  54894. };
  54895. }
  54896. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  54897. import { Nullable } from "babylonjs/types";
  54898. import { Camera } from "babylonjs/Cameras/camera";
  54899. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54900. import { Engine } from "babylonjs/Engines/engine";
  54901. import "babylonjs/Shaders/fxaa.fragment";
  54902. import "babylonjs/Shaders/fxaa.vertex";
  54903. /**
  54904. * Fxaa post process
  54905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  54906. */
  54907. export class FxaaPostProcess extends PostProcess {
  54908. /** @hidden */
  54909. texelWidth: number;
  54910. /** @hidden */
  54911. texelHeight: number;
  54912. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54913. private _getDefines;
  54914. }
  54915. }
  54916. declare module "babylonjs/Shaders/grain.fragment" {
  54917. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54918. /** @hidden */
  54919. export var grainPixelShader: {
  54920. name: string;
  54921. shader: string;
  54922. };
  54923. }
  54924. declare module "babylonjs/PostProcesses/grainPostProcess" {
  54925. import { Nullable } from "babylonjs/types";
  54926. import { Camera } from "babylonjs/Cameras/camera";
  54927. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54928. import { Engine } from "babylonjs/Engines/engine";
  54929. import "babylonjs/Shaders/grain.fragment";
  54930. /**
  54931. * The GrainPostProcess adds noise to the image at mid luminance levels
  54932. */
  54933. export class GrainPostProcess extends PostProcess {
  54934. /**
  54935. * The intensity of the grain added (default: 30)
  54936. */
  54937. intensity: number;
  54938. /**
  54939. * If the grain should be randomized on every frame
  54940. */
  54941. animated: boolean;
  54942. /**
  54943. * Creates a new instance of @see GrainPostProcess
  54944. * @param name The name of the effect.
  54945. * @param options The required width/height ratio to downsize to before computing the render pass.
  54946. * @param camera The camera to apply the render pass to.
  54947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54948. * @param engine The engine which the post process will be applied. (default: current engine)
  54949. * @param reusable If the post process can be reused on the same frame. (default: false)
  54950. * @param textureType Type of textures used when performing the post process. (default: 0)
  54951. * @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)
  54952. */
  54953. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54954. }
  54955. }
  54956. declare module "babylonjs/Shaders/highlights.fragment" {
  54957. /** @hidden */
  54958. export var highlightsPixelShader: {
  54959. name: string;
  54960. shader: string;
  54961. };
  54962. }
  54963. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  54964. import { Nullable } from "babylonjs/types";
  54965. import { Camera } from "babylonjs/Cameras/camera";
  54966. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54967. import { Engine } from "babylonjs/Engines/engine";
  54968. import "babylonjs/Shaders/highlights.fragment";
  54969. /**
  54970. * Extracts highlights from the image
  54971. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54972. */
  54973. export class HighlightsPostProcess extends PostProcess {
  54974. /**
  54975. * Extracts highlights from the image
  54976. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  54977. * @param name The name of the effect.
  54978. * @param options The required width/height ratio to downsize to before computing the render pass.
  54979. * @param camera The camera to apply the render pass to.
  54980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54981. * @param engine The engine which the post process will be applied. (default: current engine)
  54982. * @param reusable If the post process can be reused on the same frame. (default: false)
  54983. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  54984. */
  54985. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54986. }
  54987. }
  54988. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  54989. /** @hidden */
  54990. export var mrtFragmentDeclaration: {
  54991. name: string;
  54992. shader: string;
  54993. };
  54994. }
  54995. declare module "babylonjs/Shaders/geometry.fragment" {
  54996. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  54997. /** @hidden */
  54998. export var geometryPixelShader: {
  54999. name: string;
  55000. shader: string;
  55001. };
  55002. }
  55003. declare module "babylonjs/Shaders/geometry.vertex" {
  55004. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55005. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55006. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55007. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55008. /** @hidden */
  55009. export var geometryVertexShader: {
  55010. name: string;
  55011. shader: string;
  55012. };
  55013. }
  55014. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55015. import { Matrix } from "babylonjs/Maths/math";
  55016. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55017. import { Mesh } from "babylonjs/Meshes/mesh";
  55018. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55019. import { Effect } from "babylonjs/Materials/effect";
  55020. import { Scene } from "babylonjs/scene";
  55021. import "babylonjs/Shaders/geometry.fragment";
  55022. import "babylonjs/Shaders/geometry.vertex";
  55023. /**
  55024. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55025. */
  55026. export class GeometryBufferRenderer {
  55027. /**
  55028. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55029. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55030. */
  55031. static readonly POSITION_TEXTURE_TYPE: number;
  55032. /**
  55033. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55034. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55035. */
  55036. static readonly VELOCITY_TEXTURE_TYPE: number;
  55037. /**
  55038. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55039. * in order to compute objects velocities when enableVelocity is set to "true"
  55040. * @hidden
  55041. */
  55042. _previousTransformationMatrices: {
  55043. [index: number]: Matrix;
  55044. };
  55045. private _scene;
  55046. private _multiRenderTarget;
  55047. private _ratio;
  55048. private _enablePosition;
  55049. private _enableVelocity;
  55050. private _positionIndex;
  55051. private _velocityIndex;
  55052. protected _effect: Effect;
  55053. protected _cachedDefines: string;
  55054. /**
  55055. * Set the render list (meshes to be rendered) used in the G buffer.
  55056. */
  55057. renderList: Mesh[];
  55058. /**
  55059. * Gets wether or not G buffer are supported by the running hardware.
  55060. * This requires draw buffer supports
  55061. */
  55062. readonly isSupported: boolean;
  55063. /**
  55064. * Returns the index of the given texture type in the G-Buffer textures array
  55065. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55066. * @returns the index of the given texture type in the G-Buffer textures array
  55067. */
  55068. getTextureIndex(textureType: number): number;
  55069. /**
  55070. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55071. */
  55072. /**
  55073. * Sets whether or not objects positions are enabled for the G buffer.
  55074. */
  55075. enablePosition: boolean;
  55076. /**
  55077. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55078. */
  55079. /**
  55080. * Sets wether or not objects velocities are enabled for the G buffer.
  55081. */
  55082. enableVelocity: boolean;
  55083. /**
  55084. * Gets the scene associated with the buffer.
  55085. */
  55086. readonly scene: Scene;
  55087. /**
  55088. * Gets the ratio used by the buffer during its creation.
  55089. * How big is the buffer related to the main canvas.
  55090. */
  55091. readonly ratio: number;
  55092. /** @hidden */
  55093. static _SceneComponentInitialization: (scene: Scene) => void;
  55094. /**
  55095. * Creates a new G Buffer for the scene
  55096. * @param scene The scene the buffer belongs to
  55097. * @param ratio How big is the buffer related to the main canvas.
  55098. */
  55099. constructor(scene: Scene, ratio?: number);
  55100. /**
  55101. * Checks wether everything is ready to render a submesh to the G buffer.
  55102. * @param subMesh the submesh to check readiness for
  55103. * @param useInstances is the mesh drawn using instance or not
  55104. * @returns true if ready otherwise false
  55105. */
  55106. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55107. /**
  55108. * Gets the current underlying G Buffer.
  55109. * @returns the buffer
  55110. */
  55111. getGBuffer(): MultiRenderTarget;
  55112. /**
  55113. * Gets the number of samples used to render the buffer (anti aliasing).
  55114. */
  55115. /**
  55116. * Sets the number of samples used to render the buffer (anti aliasing).
  55117. */
  55118. samples: number;
  55119. /**
  55120. * Disposes the renderer and frees up associated resources.
  55121. */
  55122. dispose(): void;
  55123. protected _createRenderTargets(): void;
  55124. }
  55125. }
  55126. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55127. import { Nullable } from "babylonjs/types";
  55128. import { Scene } from "babylonjs/scene";
  55129. import { ISceneComponent } from "babylonjs/sceneComponent";
  55130. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55131. module "babylonjs/scene" {
  55132. interface Scene {
  55133. /** @hidden (Backing field) */
  55134. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55135. /**
  55136. * Gets or Sets the current geometry buffer associated to the scene.
  55137. */
  55138. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55139. /**
  55140. * Enables a GeometryBufferRender and associates it with the scene
  55141. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55142. * @returns the GeometryBufferRenderer
  55143. */
  55144. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55145. /**
  55146. * Disables the GeometryBufferRender associated with the scene
  55147. */
  55148. disableGeometryBufferRenderer(): void;
  55149. }
  55150. }
  55151. /**
  55152. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55153. * in several rendering techniques.
  55154. */
  55155. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55156. /**
  55157. * The component name helpful to identify the component in the list of scene components.
  55158. */
  55159. readonly name: string;
  55160. /**
  55161. * The scene the component belongs to.
  55162. */
  55163. scene: Scene;
  55164. /**
  55165. * Creates a new instance of the component for the given scene
  55166. * @param scene Defines the scene to register the component in
  55167. */
  55168. constructor(scene: Scene);
  55169. /**
  55170. * Registers the component in a given scene
  55171. */
  55172. register(): void;
  55173. /**
  55174. * Rebuilds the elements related to this component in case of
  55175. * context lost for instance.
  55176. */
  55177. rebuild(): void;
  55178. /**
  55179. * Disposes the component and the associated ressources
  55180. */
  55181. dispose(): void;
  55182. private _gatherRenderTargets;
  55183. }
  55184. }
  55185. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55186. /** @hidden */
  55187. export var motionBlurPixelShader: {
  55188. name: string;
  55189. shader: string;
  55190. };
  55191. }
  55192. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55193. import { Nullable } from "babylonjs/types";
  55194. import { Camera } from "babylonjs/Cameras/camera";
  55195. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55196. import { Scene } from "babylonjs/scene";
  55197. import "babylonjs/Animations/animatable";
  55198. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55199. import "babylonjs/Shaders/motionBlur.fragment";
  55200. import { Engine } from "babylonjs/Engines/engine";
  55201. /**
  55202. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55203. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55204. * As an example, all you have to do is to create the post-process:
  55205. * var mb = new BABYLON.MotionBlurPostProcess(
  55206. * 'mb', // The name of the effect.
  55207. * scene, // The scene containing the objects to blur according to their velocity.
  55208. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55209. * camera // The camera to apply the render pass to.
  55210. * );
  55211. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55212. */
  55213. export class MotionBlurPostProcess extends PostProcess {
  55214. /**
  55215. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55216. */
  55217. motionStrength: number;
  55218. /**
  55219. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55220. */
  55221. /**
  55222. * Sets the number of iterations to be used for motion blur quality
  55223. */
  55224. motionBlurSamples: number;
  55225. private _motionBlurSamples;
  55226. private _geometryBufferRenderer;
  55227. /**
  55228. * Creates a new instance MotionBlurPostProcess
  55229. * @param name The name of the effect.
  55230. * @param scene The scene containing the objects to blur according to their velocity.
  55231. * @param options The required width/height ratio to downsize to before computing the render pass.
  55232. * @param camera The camera to apply the render pass to.
  55233. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55234. * @param engine The engine which the post process will be applied. (default: current engine)
  55235. * @param reusable If the post process can be reused on the same frame. (default: false)
  55236. * @param textureType Type of textures used when performing the post process. (default: 0)
  55237. * @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)
  55238. */
  55239. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55240. /**
  55241. * Disposes the post process.
  55242. * @param camera The camera to dispose the post process on.
  55243. */
  55244. dispose(camera?: Camera): void;
  55245. }
  55246. }
  55247. declare module "babylonjs/Shaders/refraction.fragment" {
  55248. /** @hidden */
  55249. export var refractionPixelShader: {
  55250. name: string;
  55251. shader: string;
  55252. };
  55253. }
  55254. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55255. import { Color3 } from "babylonjs/Maths/math";
  55256. import { Camera } from "babylonjs/Cameras/camera";
  55257. import { Texture } from "babylonjs/Materials/Textures/texture";
  55258. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55259. import { Engine } from "babylonjs/Engines/engine";
  55260. import "babylonjs/Shaders/refraction.fragment";
  55261. /**
  55262. * Post process which applies a refractin texture
  55263. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55264. */
  55265. export class RefractionPostProcess extends PostProcess {
  55266. /** the base color of the refraction (used to taint the rendering) */
  55267. color: Color3;
  55268. /** simulated refraction depth */
  55269. depth: number;
  55270. /** the coefficient of the base color (0 to remove base color tainting) */
  55271. colorLevel: number;
  55272. private _refTexture;
  55273. private _ownRefractionTexture;
  55274. /**
  55275. * Gets or sets the refraction texture
  55276. * Please note that you are responsible for disposing the texture if you set it manually
  55277. */
  55278. refractionTexture: Texture;
  55279. /**
  55280. * Initializes the RefractionPostProcess
  55281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55282. * @param name The name of the effect.
  55283. * @param refractionTextureUrl Url of the refraction texture to use
  55284. * @param color the base color of the refraction (used to taint the rendering)
  55285. * @param depth simulated refraction depth
  55286. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55287. * @param camera The camera to apply the render pass to.
  55288. * @param options The required width/height ratio to downsize to before computing the render pass.
  55289. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55290. * @param engine The engine which the post process will be applied. (default: current engine)
  55291. * @param reusable If the post process can be reused on the same frame. (default: false)
  55292. */
  55293. constructor(name: string, refractionTextureUrl: string,
  55294. /** the base color of the refraction (used to taint the rendering) */
  55295. color: Color3,
  55296. /** simulated refraction depth */
  55297. depth: number,
  55298. /** the coefficient of the base color (0 to remove base color tainting) */
  55299. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55300. /**
  55301. * Disposes of the post process
  55302. * @param camera Camera to dispose post process on
  55303. */
  55304. dispose(camera: Camera): void;
  55305. }
  55306. }
  55307. declare module "babylonjs/Shaders/sharpen.fragment" {
  55308. /** @hidden */
  55309. export var sharpenPixelShader: {
  55310. name: string;
  55311. shader: string;
  55312. };
  55313. }
  55314. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55315. import { Nullable } from "babylonjs/types";
  55316. import { Camera } from "babylonjs/Cameras/camera";
  55317. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55318. import "babylonjs/Shaders/sharpen.fragment";
  55319. import { Engine } from "babylonjs/Engines/engine";
  55320. /**
  55321. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55322. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55323. */
  55324. export class SharpenPostProcess extends PostProcess {
  55325. /**
  55326. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55327. */
  55328. colorAmount: number;
  55329. /**
  55330. * How much sharpness should be applied (default: 0.3)
  55331. */
  55332. edgeAmount: number;
  55333. /**
  55334. * Creates a new instance ConvolutionPostProcess
  55335. * @param name The name of the effect.
  55336. * @param options The required width/height ratio to downsize to before computing the render pass.
  55337. * @param camera The camera to apply the render pass to.
  55338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55339. * @param engine The engine which the post process will be applied. (default: current engine)
  55340. * @param reusable If the post process can be reused on the same frame. (default: false)
  55341. * @param textureType Type of textures used when performing the post process. (default: 0)
  55342. * @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)
  55343. */
  55344. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55345. }
  55346. }
  55347. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55348. import { Nullable } from "babylonjs/types";
  55349. import { Camera } from "babylonjs/Cameras/camera";
  55350. import { Engine } from "babylonjs/Engines/engine";
  55351. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55352. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55353. /**
  55354. * PostProcessRenderPipeline
  55355. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55356. */
  55357. export class PostProcessRenderPipeline {
  55358. private engine;
  55359. private _renderEffects;
  55360. private _renderEffectsForIsolatedPass;
  55361. /**
  55362. * List of inspectable custom properties (used by the Inspector)
  55363. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55364. */
  55365. inspectableCustomProperties: IInspectable[];
  55366. /**
  55367. * @hidden
  55368. */
  55369. protected _cameras: Camera[];
  55370. /** @hidden */
  55371. _name: string;
  55372. /**
  55373. * Gets pipeline name
  55374. */
  55375. readonly name: string;
  55376. /**
  55377. * Initializes a PostProcessRenderPipeline
  55378. * @param engine engine to add the pipeline to
  55379. * @param name name of the pipeline
  55380. */
  55381. constructor(engine: Engine, name: string);
  55382. /**
  55383. * Gets the class name
  55384. * @returns "PostProcessRenderPipeline"
  55385. */
  55386. getClassName(): string;
  55387. /**
  55388. * If all the render effects in the pipeline are supported
  55389. */
  55390. readonly isSupported: boolean;
  55391. /**
  55392. * Adds an effect to the pipeline
  55393. * @param renderEffect the effect to add
  55394. */
  55395. addEffect(renderEffect: PostProcessRenderEffect): void;
  55396. /** @hidden */
  55397. _rebuild(): void;
  55398. /** @hidden */
  55399. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55400. /** @hidden */
  55401. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55402. /** @hidden */
  55403. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55404. /** @hidden */
  55405. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55406. /** @hidden */
  55407. _attachCameras(cameras: Camera, unique: boolean): void;
  55408. /** @hidden */
  55409. _attachCameras(cameras: Camera[], unique: boolean): void;
  55410. /** @hidden */
  55411. _detachCameras(cameras: Camera): void;
  55412. /** @hidden */
  55413. _detachCameras(cameras: Nullable<Camera[]>): void;
  55414. /** @hidden */
  55415. _update(): void;
  55416. /** @hidden */
  55417. _reset(): void;
  55418. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55419. /**
  55420. * Disposes of the pipeline
  55421. */
  55422. dispose(): void;
  55423. }
  55424. }
  55425. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55426. import { Camera } from "babylonjs/Cameras/camera";
  55427. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55428. /**
  55429. * PostProcessRenderPipelineManager class
  55430. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55431. */
  55432. export class PostProcessRenderPipelineManager {
  55433. private _renderPipelines;
  55434. /**
  55435. * Initializes a PostProcessRenderPipelineManager
  55436. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55437. */
  55438. constructor();
  55439. /**
  55440. * Gets the list of supported render pipelines
  55441. */
  55442. readonly supportedPipelines: PostProcessRenderPipeline[];
  55443. /**
  55444. * Adds a pipeline to the manager
  55445. * @param renderPipeline The pipeline to add
  55446. */
  55447. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55448. /**
  55449. * Attaches a camera to the pipeline
  55450. * @param renderPipelineName The name of the pipeline to attach to
  55451. * @param cameras the camera to attach
  55452. * @param unique if the camera can be attached multiple times to the pipeline
  55453. */
  55454. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55455. /**
  55456. * Detaches a camera from the pipeline
  55457. * @param renderPipelineName The name of the pipeline to detach from
  55458. * @param cameras the camera to detach
  55459. */
  55460. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55461. /**
  55462. * Enables an effect by name on a pipeline
  55463. * @param renderPipelineName the name of the pipeline to enable the effect in
  55464. * @param renderEffectName the name of the effect to enable
  55465. * @param cameras the cameras that the effect should be enabled on
  55466. */
  55467. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55468. /**
  55469. * Disables an effect by name on a pipeline
  55470. * @param renderPipelineName the name of the pipeline to disable the effect in
  55471. * @param renderEffectName the name of the effect to disable
  55472. * @param cameras the cameras that the effect should be disabled on
  55473. */
  55474. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55475. /**
  55476. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55477. */
  55478. update(): void;
  55479. /** @hidden */
  55480. _rebuild(): void;
  55481. /**
  55482. * Disposes of the manager and pipelines
  55483. */
  55484. dispose(): void;
  55485. }
  55486. }
  55487. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55488. import { ISceneComponent } from "babylonjs/sceneComponent";
  55489. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55490. import { Scene } from "babylonjs/scene";
  55491. module "babylonjs/scene" {
  55492. interface Scene {
  55493. /** @hidden (Backing field) */
  55494. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55495. /**
  55496. * Gets the postprocess render pipeline manager
  55497. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55498. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55499. */
  55500. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55501. }
  55502. }
  55503. /**
  55504. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55505. */
  55506. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55507. /**
  55508. * The component name helpfull to identify the component in the list of scene components.
  55509. */
  55510. readonly name: string;
  55511. /**
  55512. * The scene the component belongs to.
  55513. */
  55514. scene: Scene;
  55515. /**
  55516. * Creates a new instance of the component for the given scene
  55517. * @param scene Defines the scene to register the component in
  55518. */
  55519. constructor(scene: Scene);
  55520. /**
  55521. * Registers the component in a given scene
  55522. */
  55523. register(): void;
  55524. /**
  55525. * Rebuilds the elements related to this component in case of
  55526. * context lost for instance.
  55527. */
  55528. rebuild(): void;
  55529. /**
  55530. * Disposes the component and the associated ressources
  55531. */
  55532. dispose(): void;
  55533. private _gatherRenderTargets;
  55534. }
  55535. }
  55536. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55537. import { IAnimatable } from "babylonjs/Misc/tools";
  55538. import { Camera } from "babylonjs/Cameras/camera";
  55539. import { IDisposable } from "babylonjs/scene";
  55540. import { Scene } from "babylonjs/scene";
  55541. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55542. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55543. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55544. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55545. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55546. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55547. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55548. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55549. import { Animation } from "babylonjs/Animations/animation";
  55550. /**
  55551. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55552. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55553. */
  55554. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55555. private _scene;
  55556. private _camerasToBeAttached;
  55557. /**
  55558. * ID of the sharpen post process,
  55559. */
  55560. private readonly SharpenPostProcessId;
  55561. /**
  55562. * @ignore
  55563. * ID of the image processing post process;
  55564. */
  55565. readonly ImageProcessingPostProcessId: string;
  55566. /**
  55567. * @ignore
  55568. * ID of the Fast Approximate Anti-Aliasing post process;
  55569. */
  55570. readonly FxaaPostProcessId: string;
  55571. /**
  55572. * ID of the chromatic aberration post process,
  55573. */
  55574. private readonly ChromaticAberrationPostProcessId;
  55575. /**
  55576. * ID of the grain post process
  55577. */
  55578. private readonly GrainPostProcessId;
  55579. /**
  55580. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55581. */
  55582. sharpen: SharpenPostProcess;
  55583. private _sharpenEffect;
  55584. private bloom;
  55585. /**
  55586. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55587. */
  55588. depthOfField: DepthOfFieldEffect;
  55589. /**
  55590. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55591. */
  55592. fxaa: FxaaPostProcess;
  55593. /**
  55594. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55595. */
  55596. imageProcessing: ImageProcessingPostProcess;
  55597. /**
  55598. * Chromatic aberration post process which will shift rgb colors in the image
  55599. */
  55600. chromaticAberration: ChromaticAberrationPostProcess;
  55601. private _chromaticAberrationEffect;
  55602. /**
  55603. * Grain post process which add noise to the image
  55604. */
  55605. grain: GrainPostProcess;
  55606. private _grainEffect;
  55607. /**
  55608. * Glow post process which adds a glow to emissive areas of the image
  55609. */
  55610. private _glowLayer;
  55611. /**
  55612. * Animations which can be used to tweak settings over a period of time
  55613. */
  55614. animations: Animation[];
  55615. private _imageProcessingConfigurationObserver;
  55616. private _sharpenEnabled;
  55617. private _bloomEnabled;
  55618. private _depthOfFieldEnabled;
  55619. private _depthOfFieldBlurLevel;
  55620. private _fxaaEnabled;
  55621. private _imageProcessingEnabled;
  55622. private _defaultPipelineTextureType;
  55623. private _bloomScale;
  55624. private _chromaticAberrationEnabled;
  55625. private _grainEnabled;
  55626. private _buildAllowed;
  55627. /**
  55628. * Gets active scene
  55629. */
  55630. readonly scene: Scene;
  55631. /**
  55632. * Enable or disable the sharpen process from the pipeline
  55633. */
  55634. sharpenEnabled: boolean;
  55635. private _resizeObserver;
  55636. private _hardwareScaleLevel;
  55637. private _bloomKernel;
  55638. /**
  55639. * Specifies the size of the bloom blur kernel, relative to the final output size
  55640. */
  55641. bloomKernel: number;
  55642. /**
  55643. * Specifies the weight of the bloom in the final rendering
  55644. */
  55645. private _bloomWeight;
  55646. /**
  55647. * Specifies the luma threshold for the area that will be blurred by the bloom
  55648. */
  55649. private _bloomThreshold;
  55650. private _hdr;
  55651. /**
  55652. * The strength of the bloom.
  55653. */
  55654. bloomWeight: number;
  55655. /**
  55656. * The strength of the bloom.
  55657. */
  55658. bloomThreshold: number;
  55659. /**
  55660. * The scale of the bloom, lower value will provide better performance.
  55661. */
  55662. bloomScale: number;
  55663. /**
  55664. * Enable or disable the bloom from the pipeline
  55665. */
  55666. bloomEnabled: boolean;
  55667. private _rebuildBloom;
  55668. /**
  55669. * If the depth of field is enabled.
  55670. */
  55671. depthOfFieldEnabled: boolean;
  55672. /**
  55673. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55674. */
  55675. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55676. /**
  55677. * If the anti aliasing is enabled.
  55678. */
  55679. fxaaEnabled: boolean;
  55680. private _samples;
  55681. /**
  55682. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55683. */
  55684. samples: number;
  55685. /**
  55686. * If image processing is enabled.
  55687. */
  55688. imageProcessingEnabled: boolean;
  55689. /**
  55690. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55691. */
  55692. glowLayerEnabled: boolean;
  55693. /**
  55694. * Enable or disable the chromaticAberration process from the pipeline
  55695. */
  55696. chromaticAberrationEnabled: boolean;
  55697. /**
  55698. * Enable or disable the grain process from the pipeline
  55699. */
  55700. grainEnabled: boolean;
  55701. /**
  55702. * @constructor
  55703. * @param name - The rendering pipeline name (default: "")
  55704. * @param hdr - If high dynamic range textures should be used (default: true)
  55705. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55706. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55707. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55708. */
  55709. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55710. /**
  55711. * Get the class name
  55712. * @returns "DefaultRenderingPipeline"
  55713. */
  55714. getClassName(): string;
  55715. /**
  55716. * Force the compilation of the entire pipeline.
  55717. */
  55718. prepare(): void;
  55719. private _hasCleared;
  55720. private _prevPostProcess;
  55721. private _prevPrevPostProcess;
  55722. private _setAutoClearAndTextureSharing;
  55723. private _depthOfFieldSceneObserver;
  55724. private _buildPipeline;
  55725. private _disposePostProcesses;
  55726. /**
  55727. * Adds a camera to the pipeline
  55728. * @param camera the camera to be added
  55729. */
  55730. addCamera(camera: Camera): void;
  55731. /**
  55732. * Removes a camera from the pipeline
  55733. * @param camera the camera to remove
  55734. */
  55735. removeCamera(camera: Camera): void;
  55736. /**
  55737. * Dispose of the pipeline and stop all post processes
  55738. */
  55739. dispose(): void;
  55740. /**
  55741. * Serialize the rendering pipeline (Used when exporting)
  55742. * @returns the serialized object
  55743. */
  55744. serialize(): any;
  55745. /**
  55746. * Parse the serialized pipeline
  55747. * @param source Source pipeline.
  55748. * @param scene The scene to load the pipeline to.
  55749. * @param rootUrl The URL of the serialized pipeline.
  55750. * @returns An instantiated pipeline from the serialized object.
  55751. */
  55752. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55753. }
  55754. }
  55755. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55756. /** @hidden */
  55757. export var lensHighlightsPixelShader: {
  55758. name: string;
  55759. shader: string;
  55760. };
  55761. }
  55762. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55763. /** @hidden */
  55764. export var depthOfFieldPixelShader: {
  55765. name: string;
  55766. shader: string;
  55767. };
  55768. }
  55769. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55770. import { Camera } from "babylonjs/Cameras/camera";
  55771. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55772. import { Scene } from "babylonjs/scene";
  55773. import "babylonjs/Shaders/chromaticAberration.fragment";
  55774. import "babylonjs/Shaders/lensHighlights.fragment";
  55775. import "babylonjs/Shaders/depthOfField.fragment";
  55776. /**
  55777. * BABYLON.JS Chromatic Aberration GLSL Shader
  55778. * Author: Olivier Guyot
  55779. * Separates very slightly R, G and B colors on the edges of the screen
  55780. * Inspired by Francois Tarlier & Martins Upitis
  55781. */
  55782. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55783. /**
  55784. * @ignore
  55785. * The chromatic aberration PostProcess id in the pipeline
  55786. */
  55787. LensChromaticAberrationEffect: string;
  55788. /**
  55789. * @ignore
  55790. * The highlights enhancing PostProcess id in the pipeline
  55791. */
  55792. HighlightsEnhancingEffect: string;
  55793. /**
  55794. * @ignore
  55795. * The depth-of-field PostProcess id in the pipeline
  55796. */
  55797. LensDepthOfFieldEffect: string;
  55798. private _scene;
  55799. private _depthTexture;
  55800. private _grainTexture;
  55801. private _chromaticAberrationPostProcess;
  55802. private _highlightsPostProcess;
  55803. private _depthOfFieldPostProcess;
  55804. private _edgeBlur;
  55805. private _grainAmount;
  55806. private _chromaticAberration;
  55807. private _distortion;
  55808. private _highlightsGain;
  55809. private _highlightsThreshold;
  55810. private _dofDistance;
  55811. private _dofAperture;
  55812. private _dofDarken;
  55813. private _dofPentagon;
  55814. private _blurNoise;
  55815. /**
  55816. * @constructor
  55817. *
  55818. * Effect parameters are as follow:
  55819. * {
  55820. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55821. * edge_blur: number; // from 0 to x (1 for realism)
  55822. * distortion: number; // from 0 to x (1 for realism)
  55823. * grain_amount: number; // from 0 to 1
  55824. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55825. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55826. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55827. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55828. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55829. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55830. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55831. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55832. * }
  55833. * Note: if an effect parameter is unset, effect is disabled
  55834. *
  55835. * @param name The rendering pipeline name
  55836. * @param parameters - An object containing all parameters (see above)
  55837. * @param scene The scene linked to this pipeline
  55838. * @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)
  55839. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55840. */
  55841. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55842. /**
  55843. * Get the class name
  55844. * @returns "LensRenderingPipeline"
  55845. */
  55846. getClassName(): string;
  55847. /**
  55848. * Gets associated scene
  55849. */
  55850. readonly scene: Scene;
  55851. /**
  55852. * Gets or sets the edge blur
  55853. */
  55854. edgeBlur: number;
  55855. /**
  55856. * Gets or sets the grain amount
  55857. */
  55858. grainAmount: number;
  55859. /**
  55860. * Gets or sets the chromatic aberration amount
  55861. */
  55862. chromaticAberration: number;
  55863. /**
  55864. * Gets or sets the depth of field aperture
  55865. */
  55866. dofAperture: number;
  55867. /**
  55868. * Gets or sets the edge distortion
  55869. */
  55870. edgeDistortion: number;
  55871. /**
  55872. * Gets or sets the depth of field distortion
  55873. */
  55874. dofDistortion: number;
  55875. /**
  55876. * Gets or sets the darken out of focus amount
  55877. */
  55878. darkenOutOfFocus: number;
  55879. /**
  55880. * Gets or sets a boolean indicating if blur noise is enabled
  55881. */
  55882. blurNoise: boolean;
  55883. /**
  55884. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  55885. */
  55886. pentagonBokeh: boolean;
  55887. /**
  55888. * Gets or sets the highlight grain amount
  55889. */
  55890. highlightsGain: number;
  55891. /**
  55892. * Gets or sets the highlight threshold
  55893. */
  55894. highlightsThreshold: number;
  55895. /**
  55896. * Sets the amount of blur at the edges
  55897. * @param amount blur amount
  55898. */
  55899. setEdgeBlur(amount: number): void;
  55900. /**
  55901. * Sets edge blur to 0
  55902. */
  55903. disableEdgeBlur(): void;
  55904. /**
  55905. * Sets the amout of grain
  55906. * @param amount Amount of grain
  55907. */
  55908. setGrainAmount(amount: number): void;
  55909. /**
  55910. * Set grain amount to 0
  55911. */
  55912. disableGrain(): void;
  55913. /**
  55914. * Sets the chromatic aberration amount
  55915. * @param amount amount of chromatic aberration
  55916. */
  55917. setChromaticAberration(amount: number): void;
  55918. /**
  55919. * Sets chromatic aberration amount to 0
  55920. */
  55921. disableChromaticAberration(): void;
  55922. /**
  55923. * Sets the EdgeDistortion amount
  55924. * @param amount amount of EdgeDistortion
  55925. */
  55926. setEdgeDistortion(amount: number): void;
  55927. /**
  55928. * Sets edge distortion to 0
  55929. */
  55930. disableEdgeDistortion(): void;
  55931. /**
  55932. * Sets the FocusDistance amount
  55933. * @param amount amount of FocusDistance
  55934. */
  55935. setFocusDistance(amount: number): void;
  55936. /**
  55937. * Disables depth of field
  55938. */
  55939. disableDepthOfField(): void;
  55940. /**
  55941. * Sets the Aperture amount
  55942. * @param amount amount of Aperture
  55943. */
  55944. setAperture(amount: number): void;
  55945. /**
  55946. * Sets the DarkenOutOfFocus amount
  55947. * @param amount amount of DarkenOutOfFocus
  55948. */
  55949. setDarkenOutOfFocus(amount: number): void;
  55950. private _pentagonBokehIsEnabled;
  55951. /**
  55952. * Creates a pentagon bokeh effect
  55953. */
  55954. enablePentagonBokeh(): void;
  55955. /**
  55956. * Disables the pentagon bokeh effect
  55957. */
  55958. disablePentagonBokeh(): void;
  55959. /**
  55960. * Enables noise blur
  55961. */
  55962. enableNoiseBlur(): void;
  55963. /**
  55964. * Disables noise blur
  55965. */
  55966. disableNoiseBlur(): void;
  55967. /**
  55968. * Sets the HighlightsGain amount
  55969. * @param amount amount of HighlightsGain
  55970. */
  55971. setHighlightsGain(amount: number): void;
  55972. /**
  55973. * Sets the HighlightsThreshold amount
  55974. * @param amount amount of HighlightsThreshold
  55975. */
  55976. setHighlightsThreshold(amount: number): void;
  55977. /**
  55978. * Disables highlights
  55979. */
  55980. disableHighlights(): void;
  55981. /**
  55982. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  55983. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  55984. */
  55985. dispose(disableDepthRender?: boolean): void;
  55986. private _createChromaticAberrationPostProcess;
  55987. private _createHighlightsPostProcess;
  55988. private _createDepthOfFieldPostProcess;
  55989. private _createGrainTexture;
  55990. }
  55991. }
  55992. declare module "babylonjs/Shaders/ssao2.fragment" {
  55993. /** @hidden */
  55994. export var ssao2PixelShader: {
  55995. name: string;
  55996. shader: string;
  55997. };
  55998. }
  55999. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56000. /** @hidden */
  56001. export var ssaoCombinePixelShader: {
  56002. name: string;
  56003. shader: string;
  56004. };
  56005. }
  56006. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56007. import { Camera } from "babylonjs/Cameras/camera";
  56008. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56009. import { Scene } from "babylonjs/scene";
  56010. import "babylonjs/Shaders/ssao2.fragment";
  56011. import "babylonjs/Shaders/ssaoCombine.fragment";
  56012. /**
  56013. * Render pipeline to produce ssao effect
  56014. */
  56015. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56016. /**
  56017. * @ignore
  56018. * The PassPostProcess id in the pipeline that contains the original scene color
  56019. */
  56020. SSAOOriginalSceneColorEffect: string;
  56021. /**
  56022. * @ignore
  56023. * The SSAO PostProcess id in the pipeline
  56024. */
  56025. SSAORenderEffect: string;
  56026. /**
  56027. * @ignore
  56028. * The horizontal blur PostProcess id in the pipeline
  56029. */
  56030. SSAOBlurHRenderEffect: string;
  56031. /**
  56032. * @ignore
  56033. * The vertical blur PostProcess id in the pipeline
  56034. */
  56035. SSAOBlurVRenderEffect: string;
  56036. /**
  56037. * @ignore
  56038. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56039. */
  56040. SSAOCombineRenderEffect: string;
  56041. /**
  56042. * The output strength of the SSAO post-process. Default value is 1.0.
  56043. */
  56044. totalStrength: number;
  56045. /**
  56046. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56047. */
  56048. maxZ: number;
  56049. /**
  56050. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56051. */
  56052. minZAspect: number;
  56053. private _samples;
  56054. /**
  56055. * Number of samples used for the SSAO calculations. Default value is 8
  56056. */
  56057. samples: number;
  56058. private _textureSamples;
  56059. /**
  56060. * Number of samples to use for antialiasing
  56061. */
  56062. textureSamples: number;
  56063. /**
  56064. * Ratio object used for SSAO ratio and blur ratio
  56065. */
  56066. private _ratio;
  56067. /**
  56068. * Dynamically generated sphere sampler.
  56069. */
  56070. private _sampleSphere;
  56071. /**
  56072. * Blur filter offsets
  56073. */
  56074. private _samplerOffsets;
  56075. private _expensiveBlur;
  56076. /**
  56077. * If bilateral blur should be used
  56078. */
  56079. expensiveBlur: boolean;
  56080. /**
  56081. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56082. */
  56083. radius: number;
  56084. /**
  56085. * The base color of the SSAO post-process
  56086. * The final result is "base + ssao" between [0, 1]
  56087. */
  56088. base: number;
  56089. /**
  56090. * Support test.
  56091. */
  56092. static readonly IsSupported: boolean;
  56093. private _scene;
  56094. private _depthTexture;
  56095. private _normalTexture;
  56096. private _randomTexture;
  56097. private _originalColorPostProcess;
  56098. private _ssaoPostProcess;
  56099. private _blurHPostProcess;
  56100. private _blurVPostProcess;
  56101. private _ssaoCombinePostProcess;
  56102. private _firstUpdate;
  56103. /**
  56104. * Gets active scene
  56105. */
  56106. readonly scene: Scene;
  56107. /**
  56108. * @constructor
  56109. * @param name The rendering pipeline name
  56110. * @param scene The scene linked to this pipeline
  56111. * @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 }
  56112. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56113. */
  56114. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56115. /**
  56116. * Get the class name
  56117. * @returns "SSAO2RenderingPipeline"
  56118. */
  56119. getClassName(): string;
  56120. /**
  56121. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56122. */
  56123. dispose(disableGeometryBufferRenderer?: boolean): void;
  56124. private _createBlurPostProcess;
  56125. /** @hidden */
  56126. _rebuild(): void;
  56127. private _bits;
  56128. private _radicalInverse_VdC;
  56129. private _hammersley;
  56130. private _hemisphereSample_uniform;
  56131. private _generateHemisphere;
  56132. private _createSSAOPostProcess;
  56133. private _createSSAOCombinePostProcess;
  56134. private _createRandomTexture;
  56135. /**
  56136. * Serialize the rendering pipeline (Used when exporting)
  56137. * @returns the serialized object
  56138. */
  56139. serialize(): any;
  56140. /**
  56141. * Parse the serialized pipeline
  56142. * @param source Source pipeline.
  56143. * @param scene The scene to load the pipeline to.
  56144. * @param rootUrl The URL of the serialized pipeline.
  56145. * @returns An instantiated pipeline from the serialized object.
  56146. */
  56147. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56148. }
  56149. }
  56150. declare module "babylonjs/Shaders/ssao.fragment" {
  56151. /** @hidden */
  56152. export var ssaoPixelShader: {
  56153. name: string;
  56154. shader: string;
  56155. };
  56156. }
  56157. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56158. import { Camera } from "babylonjs/Cameras/camera";
  56159. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56160. import { Scene } from "babylonjs/scene";
  56161. import "babylonjs/Shaders/ssao.fragment";
  56162. import "babylonjs/Shaders/ssaoCombine.fragment";
  56163. /**
  56164. * Render pipeline to produce ssao effect
  56165. */
  56166. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56167. /**
  56168. * @ignore
  56169. * The PassPostProcess id in the pipeline that contains the original scene color
  56170. */
  56171. SSAOOriginalSceneColorEffect: string;
  56172. /**
  56173. * @ignore
  56174. * The SSAO PostProcess id in the pipeline
  56175. */
  56176. SSAORenderEffect: string;
  56177. /**
  56178. * @ignore
  56179. * The horizontal blur PostProcess id in the pipeline
  56180. */
  56181. SSAOBlurHRenderEffect: string;
  56182. /**
  56183. * @ignore
  56184. * The vertical blur PostProcess id in the pipeline
  56185. */
  56186. SSAOBlurVRenderEffect: string;
  56187. /**
  56188. * @ignore
  56189. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56190. */
  56191. SSAOCombineRenderEffect: string;
  56192. /**
  56193. * The output strength of the SSAO post-process. Default value is 1.0.
  56194. */
  56195. totalStrength: number;
  56196. /**
  56197. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56198. */
  56199. radius: number;
  56200. /**
  56201. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56202. * Must not be equal to fallOff and superior to fallOff.
  56203. * Default value is 0.0075
  56204. */
  56205. area: number;
  56206. /**
  56207. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56208. * Must not be equal to area and inferior to area.
  56209. * Default value is 0.000001
  56210. */
  56211. fallOff: number;
  56212. /**
  56213. * The base color of the SSAO post-process
  56214. * The final result is "base + ssao" between [0, 1]
  56215. */
  56216. base: number;
  56217. private _scene;
  56218. private _depthTexture;
  56219. private _randomTexture;
  56220. private _originalColorPostProcess;
  56221. private _ssaoPostProcess;
  56222. private _blurHPostProcess;
  56223. private _blurVPostProcess;
  56224. private _ssaoCombinePostProcess;
  56225. private _firstUpdate;
  56226. /**
  56227. * Gets active scene
  56228. */
  56229. readonly scene: Scene;
  56230. /**
  56231. * @constructor
  56232. * @param name - The rendering pipeline name
  56233. * @param scene - The scene linked to this pipeline
  56234. * @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 }
  56235. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56236. */
  56237. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56238. /**
  56239. * Get the class name
  56240. * @returns "SSAORenderingPipeline"
  56241. */
  56242. getClassName(): string;
  56243. /**
  56244. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56245. */
  56246. dispose(disableDepthRender?: boolean): void;
  56247. private _createBlurPostProcess;
  56248. /** @hidden */
  56249. _rebuild(): void;
  56250. private _createSSAOPostProcess;
  56251. private _createSSAOCombinePostProcess;
  56252. private _createRandomTexture;
  56253. }
  56254. }
  56255. declare module "babylonjs/Shaders/standard.fragment" {
  56256. /** @hidden */
  56257. export var standardPixelShader: {
  56258. name: string;
  56259. shader: string;
  56260. };
  56261. }
  56262. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56263. import { Nullable } from "babylonjs/types";
  56264. import { IAnimatable } from "babylonjs/Misc/tools";
  56265. import { Camera } from "babylonjs/Cameras/camera";
  56266. import { Texture } from "babylonjs/Materials/Textures/texture";
  56267. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56268. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56269. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56270. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56271. import { IDisposable } from "babylonjs/scene";
  56272. import { SpotLight } from "babylonjs/Lights/spotLight";
  56273. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56274. import { Scene } from "babylonjs/scene";
  56275. import { Animation } from "babylonjs/Animations/animation";
  56276. import "babylonjs/Shaders/standard.fragment";
  56277. /**
  56278. * Standard rendering pipeline
  56279. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56280. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56281. */
  56282. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56283. /**
  56284. * Public members
  56285. */
  56286. /**
  56287. * Post-process which contains the original scene color before the pipeline applies all the effects
  56288. */
  56289. originalPostProcess: Nullable<PostProcess>;
  56290. /**
  56291. * Post-process used to down scale an image x4
  56292. */
  56293. downSampleX4PostProcess: Nullable<PostProcess>;
  56294. /**
  56295. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56296. */
  56297. brightPassPostProcess: Nullable<PostProcess>;
  56298. /**
  56299. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56300. */
  56301. blurHPostProcesses: PostProcess[];
  56302. /**
  56303. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56304. */
  56305. blurVPostProcesses: PostProcess[];
  56306. /**
  56307. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56308. */
  56309. textureAdderPostProcess: Nullable<PostProcess>;
  56310. /**
  56311. * Post-process used to create volumetric lighting effect
  56312. */
  56313. volumetricLightPostProcess: Nullable<PostProcess>;
  56314. /**
  56315. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56316. */
  56317. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56318. /**
  56319. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56320. */
  56321. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56322. /**
  56323. * Post-process used to merge the volumetric light effect and the real scene color
  56324. */
  56325. volumetricLightMergePostProces: Nullable<PostProcess>;
  56326. /**
  56327. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56328. */
  56329. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56330. /**
  56331. * Base post-process used to calculate the average luminance of the final image for HDR
  56332. */
  56333. luminancePostProcess: Nullable<PostProcess>;
  56334. /**
  56335. * Post-processes used to create down sample post-processes in order to get
  56336. * the average luminance of the final image for HDR
  56337. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56338. */
  56339. luminanceDownSamplePostProcesses: PostProcess[];
  56340. /**
  56341. * Post-process used to create a HDR effect (light adaptation)
  56342. */
  56343. hdrPostProcess: Nullable<PostProcess>;
  56344. /**
  56345. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56346. */
  56347. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56348. /**
  56349. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56350. */
  56351. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56352. /**
  56353. * Post-process used to merge the final HDR post-process and the real scene color
  56354. */
  56355. hdrFinalPostProcess: Nullable<PostProcess>;
  56356. /**
  56357. * Post-process used to create a lens flare effect
  56358. */
  56359. lensFlarePostProcess: Nullable<PostProcess>;
  56360. /**
  56361. * Post-process that merges the result of the lens flare post-process and the real scene color
  56362. */
  56363. lensFlareComposePostProcess: Nullable<PostProcess>;
  56364. /**
  56365. * Post-process used to create a motion blur effect
  56366. */
  56367. motionBlurPostProcess: Nullable<PostProcess>;
  56368. /**
  56369. * Post-process used to create a depth of field effect
  56370. */
  56371. depthOfFieldPostProcess: Nullable<PostProcess>;
  56372. /**
  56373. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56374. */
  56375. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56376. /**
  56377. * Represents the brightness threshold in order to configure the illuminated surfaces
  56378. */
  56379. brightThreshold: number;
  56380. /**
  56381. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56382. */
  56383. blurWidth: number;
  56384. /**
  56385. * Sets if the blur for highlighted surfaces must be only horizontal
  56386. */
  56387. horizontalBlur: boolean;
  56388. /**
  56389. * Gets the overall exposure used by the pipeline
  56390. */
  56391. /**
  56392. * Sets the overall exposure used by the pipeline
  56393. */
  56394. exposure: number;
  56395. /**
  56396. * Texture used typically to simulate "dirty" on camera lens
  56397. */
  56398. lensTexture: Nullable<Texture>;
  56399. /**
  56400. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56401. */
  56402. volumetricLightCoefficient: number;
  56403. /**
  56404. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56405. */
  56406. volumetricLightPower: number;
  56407. /**
  56408. * Used the set the blur intensity to smooth the volumetric lights
  56409. */
  56410. volumetricLightBlurScale: number;
  56411. /**
  56412. * Light (spot or directional) used to generate the volumetric lights rays
  56413. * The source light must have a shadow generate so the pipeline can get its
  56414. * depth map
  56415. */
  56416. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56417. /**
  56418. * For eye adaptation, represents the minimum luminance the eye can see
  56419. */
  56420. hdrMinimumLuminance: number;
  56421. /**
  56422. * For eye adaptation, represents the decrease luminance speed
  56423. */
  56424. hdrDecreaseRate: number;
  56425. /**
  56426. * For eye adaptation, represents the increase luminance speed
  56427. */
  56428. hdrIncreaseRate: number;
  56429. /**
  56430. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56431. */
  56432. /**
  56433. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56434. */
  56435. hdrAutoExposure: boolean;
  56436. /**
  56437. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56438. */
  56439. lensColorTexture: Nullable<Texture>;
  56440. /**
  56441. * The overall strengh for the lens flare effect
  56442. */
  56443. lensFlareStrength: number;
  56444. /**
  56445. * Dispersion coefficient for lens flare ghosts
  56446. */
  56447. lensFlareGhostDispersal: number;
  56448. /**
  56449. * Main lens flare halo width
  56450. */
  56451. lensFlareHaloWidth: number;
  56452. /**
  56453. * Based on the lens distortion effect, defines how much the lens flare result
  56454. * is distorted
  56455. */
  56456. lensFlareDistortionStrength: number;
  56457. /**
  56458. * Lens star texture must be used to simulate rays on the flares and is available
  56459. * in the documentation
  56460. */
  56461. lensStarTexture: Nullable<Texture>;
  56462. /**
  56463. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56464. * flare effect by taking account of the dirt texture
  56465. */
  56466. lensFlareDirtTexture: Nullable<Texture>;
  56467. /**
  56468. * Represents the focal length for the depth of field effect
  56469. */
  56470. depthOfFieldDistance: number;
  56471. /**
  56472. * Represents the blur intensity for the blurred part of the depth of field effect
  56473. */
  56474. depthOfFieldBlurWidth: number;
  56475. /**
  56476. * For motion blur, defines how much the image is blurred by the movement
  56477. */
  56478. motionStrength: number;
  56479. /**
  56480. * List of animations for the pipeline (IAnimatable implementation)
  56481. */
  56482. animations: Animation[];
  56483. /**
  56484. * Private members
  56485. */
  56486. private _scene;
  56487. private _currentDepthOfFieldSource;
  56488. private _basePostProcess;
  56489. private _fixedExposure;
  56490. private _currentExposure;
  56491. private _hdrAutoExposure;
  56492. private _hdrCurrentLuminance;
  56493. private _floatTextureType;
  56494. private _ratio;
  56495. private _bloomEnabled;
  56496. private _depthOfFieldEnabled;
  56497. private _vlsEnabled;
  56498. private _lensFlareEnabled;
  56499. private _hdrEnabled;
  56500. private _motionBlurEnabled;
  56501. private _fxaaEnabled;
  56502. private _motionBlurSamples;
  56503. private _volumetricLightStepsCount;
  56504. private _samples;
  56505. /**
  56506. * @ignore
  56507. * Specifies if the bloom pipeline is enabled
  56508. */
  56509. BloomEnabled: boolean;
  56510. /**
  56511. * @ignore
  56512. * Specifies if the depth of field pipeline is enabed
  56513. */
  56514. DepthOfFieldEnabled: boolean;
  56515. /**
  56516. * @ignore
  56517. * Specifies if the lens flare pipeline is enabed
  56518. */
  56519. LensFlareEnabled: boolean;
  56520. /**
  56521. * @ignore
  56522. * Specifies if the HDR pipeline is enabled
  56523. */
  56524. HDREnabled: boolean;
  56525. /**
  56526. * @ignore
  56527. * Specifies if the volumetric lights scattering effect is enabled
  56528. */
  56529. VLSEnabled: boolean;
  56530. /**
  56531. * @ignore
  56532. * Specifies if the motion blur effect is enabled
  56533. */
  56534. MotionBlurEnabled: boolean;
  56535. /**
  56536. * Specifies if anti-aliasing is enabled
  56537. */
  56538. fxaaEnabled: boolean;
  56539. /**
  56540. * Specifies the number of steps used to calculate the volumetric lights
  56541. * Typically in interval [50, 200]
  56542. */
  56543. volumetricLightStepsCount: number;
  56544. /**
  56545. * Specifies the number of samples used for the motion blur effect
  56546. * Typically in interval [16, 64]
  56547. */
  56548. motionBlurSamples: number;
  56549. /**
  56550. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56551. */
  56552. samples: number;
  56553. /**
  56554. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56555. * @constructor
  56556. * @param name The rendering pipeline name
  56557. * @param scene The scene linked to this pipeline
  56558. * @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)
  56559. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56560. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56561. */
  56562. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56563. private _buildPipeline;
  56564. private _createDownSampleX4PostProcess;
  56565. private _createBrightPassPostProcess;
  56566. private _createBlurPostProcesses;
  56567. private _createTextureAdderPostProcess;
  56568. private _createVolumetricLightPostProcess;
  56569. private _createLuminancePostProcesses;
  56570. private _createHdrPostProcess;
  56571. private _createLensFlarePostProcess;
  56572. private _createDepthOfFieldPostProcess;
  56573. private _createMotionBlurPostProcess;
  56574. private _getDepthTexture;
  56575. private _disposePostProcesses;
  56576. /**
  56577. * Dispose of the pipeline and stop all post processes
  56578. */
  56579. dispose(): void;
  56580. /**
  56581. * Serialize the rendering pipeline (Used when exporting)
  56582. * @returns the serialized object
  56583. */
  56584. serialize(): any;
  56585. /**
  56586. * Parse the serialized pipeline
  56587. * @param source Source pipeline.
  56588. * @param scene The scene to load the pipeline to.
  56589. * @param rootUrl The URL of the serialized pipeline.
  56590. * @returns An instantiated pipeline from the serialized object.
  56591. */
  56592. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56593. /**
  56594. * Luminance steps
  56595. */
  56596. static LuminanceSteps: number;
  56597. }
  56598. }
  56599. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56600. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56601. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56602. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56603. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56604. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56605. }
  56606. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56607. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56608. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56609. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56610. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56611. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56612. }
  56613. declare module "babylonjs/Shaders/tonemap.fragment" {
  56614. /** @hidden */
  56615. export var tonemapPixelShader: {
  56616. name: string;
  56617. shader: string;
  56618. };
  56619. }
  56620. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56621. import { Camera } from "babylonjs/Cameras/camera";
  56622. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56623. import "babylonjs/Shaders/tonemap.fragment";
  56624. import { Engine } from "babylonjs/Engines/engine";
  56625. /** Defines operator used for tonemapping */
  56626. export enum TonemappingOperator {
  56627. /** Hable */
  56628. Hable = 0,
  56629. /** Reinhard */
  56630. Reinhard = 1,
  56631. /** HejiDawson */
  56632. HejiDawson = 2,
  56633. /** Photographic */
  56634. Photographic = 3
  56635. }
  56636. /**
  56637. * Defines a post process to apply tone mapping
  56638. */
  56639. export class TonemapPostProcess extends PostProcess {
  56640. private _operator;
  56641. /** Defines the required exposure adjustement */
  56642. exposureAdjustment: number;
  56643. /**
  56644. * Creates a new TonemapPostProcess
  56645. * @param name defines the name of the postprocess
  56646. * @param _operator defines the operator to use
  56647. * @param exposureAdjustment defines the required exposure adjustement
  56648. * @param camera defines the camera to use (can be null)
  56649. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56650. * @param engine defines the hosting engine (can be ignore if camera is set)
  56651. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56652. */
  56653. constructor(name: string, _operator: TonemappingOperator,
  56654. /** Defines the required exposure adjustement */
  56655. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56656. }
  56657. }
  56658. declare module "babylonjs/Shaders/depth.vertex" {
  56659. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56660. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56661. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56662. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56663. /** @hidden */
  56664. export var depthVertexShader: {
  56665. name: string;
  56666. shader: string;
  56667. };
  56668. }
  56669. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56670. /** @hidden */
  56671. export var volumetricLightScatteringPixelShader: {
  56672. name: string;
  56673. shader: string;
  56674. };
  56675. }
  56676. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56677. /** @hidden */
  56678. export var volumetricLightScatteringPassPixelShader: {
  56679. name: string;
  56680. shader: string;
  56681. };
  56682. }
  56683. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56684. import { Vector3 } from "babylonjs/Maths/math";
  56685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56686. import { Mesh } from "babylonjs/Meshes/mesh";
  56687. import { Camera } from "babylonjs/Cameras/camera";
  56688. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56689. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56690. import { Scene } from "babylonjs/scene";
  56691. import "babylonjs/Meshes/Builders/planeBuilder";
  56692. import "babylonjs/Shaders/depth.vertex";
  56693. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56694. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56695. import { Engine } from "babylonjs/Engines/engine";
  56696. /**
  56697. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56698. */
  56699. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56700. private _volumetricLightScatteringPass;
  56701. private _volumetricLightScatteringRTT;
  56702. private _viewPort;
  56703. private _screenCoordinates;
  56704. private _cachedDefines;
  56705. /**
  56706. * If not undefined, the mesh position is computed from the attached node position
  56707. */
  56708. attachedNode: {
  56709. position: Vector3;
  56710. };
  56711. /**
  56712. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56713. */
  56714. customMeshPosition: Vector3;
  56715. /**
  56716. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56717. */
  56718. useCustomMeshPosition: boolean;
  56719. /**
  56720. * If the post-process should inverse the light scattering direction
  56721. */
  56722. invert: boolean;
  56723. /**
  56724. * The internal mesh used by the post-process
  56725. */
  56726. mesh: Mesh;
  56727. /**
  56728. * @hidden
  56729. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56730. */
  56731. useDiffuseColor: boolean;
  56732. /**
  56733. * Array containing the excluded meshes not rendered in the internal pass
  56734. */
  56735. excludedMeshes: AbstractMesh[];
  56736. /**
  56737. * Controls the overall intensity of the post-process
  56738. */
  56739. exposure: number;
  56740. /**
  56741. * Dissipates each sample's contribution in range [0, 1]
  56742. */
  56743. decay: number;
  56744. /**
  56745. * Controls the overall intensity of each sample
  56746. */
  56747. weight: number;
  56748. /**
  56749. * Controls the density of each sample
  56750. */
  56751. density: number;
  56752. /**
  56753. * @constructor
  56754. * @param name The post-process name
  56755. * @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)
  56756. * @param camera The camera that the post-process will be attached to
  56757. * @param mesh The mesh used to create the light scattering
  56758. * @param samples The post-process quality, default 100
  56759. * @param samplingModeThe post-process filtering mode
  56760. * @param engine The babylon engine
  56761. * @param reusable If the post-process is reusable
  56762. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56763. */
  56764. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56765. /**
  56766. * Returns the string "VolumetricLightScatteringPostProcess"
  56767. * @returns "VolumetricLightScatteringPostProcess"
  56768. */
  56769. getClassName(): string;
  56770. private _isReady;
  56771. /**
  56772. * Sets the new light position for light scattering effect
  56773. * @param position The new custom light position
  56774. */
  56775. setCustomMeshPosition(position: Vector3): void;
  56776. /**
  56777. * Returns the light position for light scattering effect
  56778. * @return Vector3 The custom light position
  56779. */
  56780. getCustomMeshPosition(): Vector3;
  56781. /**
  56782. * Disposes the internal assets and detaches the post-process from the camera
  56783. */
  56784. dispose(camera: Camera): void;
  56785. /**
  56786. * Returns the render target texture used by the post-process
  56787. * @return the render target texture used by the post-process
  56788. */
  56789. getPass(): RenderTargetTexture;
  56790. private _meshExcluded;
  56791. private _createPass;
  56792. private _updateMeshScreenCoordinates;
  56793. /**
  56794. * Creates a default mesh for the Volumeric Light Scattering post-process
  56795. * @param name The mesh name
  56796. * @param scene The scene where to create the mesh
  56797. * @return the default mesh
  56798. */
  56799. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56800. }
  56801. }
  56802. declare module "babylonjs/PostProcesses/index" {
  56803. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56804. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56805. export * from "babylonjs/PostProcesses/bloomEffect";
  56806. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56807. export * from "babylonjs/PostProcesses/blurPostProcess";
  56808. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56809. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56810. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56811. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56812. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56813. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56814. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56815. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56816. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56817. export * from "babylonjs/PostProcesses/filterPostProcess";
  56818. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56819. export * from "babylonjs/PostProcesses/grainPostProcess";
  56820. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56821. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56822. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56823. export * from "babylonjs/PostProcesses/passPostProcess";
  56824. export * from "babylonjs/PostProcesses/postProcess";
  56825. export * from "babylonjs/PostProcesses/postProcessManager";
  56826. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56827. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56828. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56829. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56830. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56831. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56832. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56833. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56834. }
  56835. declare module "babylonjs/Probes/index" {
  56836. export * from "babylonjs/Probes/reflectionProbe";
  56837. }
  56838. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56839. import { Scene } from "babylonjs/scene";
  56840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56841. import { Color3 } from "babylonjs/Maths/math";
  56842. import { SmartArray } from "babylonjs/Misc/smartArray";
  56843. import { ISceneComponent } from "babylonjs/sceneComponent";
  56844. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56845. import "babylonjs/Meshes/Builders/boxBuilder";
  56846. import "babylonjs/Shaders/color.fragment";
  56847. import "babylonjs/Shaders/color.vertex";
  56848. module "babylonjs/scene" {
  56849. interface Scene {
  56850. /** @hidden (Backing field) */
  56851. _boundingBoxRenderer: BoundingBoxRenderer;
  56852. /** @hidden (Backing field) */
  56853. _forceShowBoundingBoxes: boolean;
  56854. /**
  56855. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56856. */
  56857. forceShowBoundingBoxes: boolean;
  56858. /**
  56859. * Gets the bounding box renderer associated with the scene
  56860. * @returns a BoundingBoxRenderer
  56861. */
  56862. getBoundingBoxRenderer(): BoundingBoxRenderer;
  56863. }
  56864. }
  56865. module "babylonjs/Meshes/abstractMesh" {
  56866. interface AbstractMesh {
  56867. /** @hidden (Backing field) */
  56868. _showBoundingBox: boolean;
  56869. /**
  56870. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  56871. */
  56872. showBoundingBox: boolean;
  56873. }
  56874. }
  56875. /**
  56876. * Component responsible of rendering the bounding box of the meshes in a scene.
  56877. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  56878. */
  56879. export class BoundingBoxRenderer implements ISceneComponent {
  56880. /**
  56881. * The component name helpfull to identify the component in the list of scene components.
  56882. */
  56883. readonly name: string;
  56884. /**
  56885. * The scene the component belongs to.
  56886. */
  56887. scene: Scene;
  56888. /**
  56889. * Color of the bounding box lines placed in front of an object
  56890. */
  56891. frontColor: Color3;
  56892. /**
  56893. * Color of the bounding box lines placed behind an object
  56894. */
  56895. backColor: Color3;
  56896. /**
  56897. * Defines if the renderer should show the back lines or not
  56898. */
  56899. showBackLines: boolean;
  56900. /**
  56901. * @hidden
  56902. */
  56903. renderList: SmartArray<BoundingBox>;
  56904. private _colorShader;
  56905. private _vertexBuffers;
  56906. private _indexBuffer;
  56907. /**
  56908. * Instantiates a new bounding box renderer in a scene.
  56909. * @param scene the scene the renderer renders in
  56910. */
  56911. constructor(scene: Scene);
  56912. /**
  56913. * Registers the component in a given scene
  56914. */
  56915. register(): void;
  56916. private _evaluateSubMesh;
  56917. private _activeMesh;
  56918. private _prepareRessources;
  56919. private _createIndexBuffer;
  56920. /**
  56921. * Rebuilds the elements related to this component in case of
  56922. * context lost for instance.
  56923. */
  56924. rebuild(): void;
  56925. /**
  56926. * @hidden
  56927. */
  56928. reset(): void;
  56929. /**
  56930. * Render the bounding boxes of a specific rendering group
  56931. * @param renderingGroupId defines the rendering group to render
  56932. */
  56933. render(renderingGroupId: number): void;
  56934. /**
  56935. * In case of occlusion queries, we can render the occlusion bounding box through this method
  56936. * @param mesh Define the mesh to render the occlusion bounding box for
  56937. */
  56938. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  56939. /**
  56940. * Dispose and release the resources attached to this renderer.
  56941. */
  56942. dispose(): void;
  56943. }
  56944. }
  56945. declare module "babylonjs/Shaders/depth.fragment" {
  56946. /** @hidden */
  56947. export var depthPixelShader: {
  56948. name: string;
  56949. shader: string;
  56950. };
  56951. }
  56952. declare module "babylonjs/Rendering/depthRenderer" {
  56953. import { Nullable } from "babylonjs/types";
  56954. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56955. import { Scene } from "babylonjs/scene";
  56956. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56957. import { Camera } from "babylonjs/Cameras/camera";
  56958. import "babylonjs/Shaders/depth.fragment";
  56959. import "babylonjs/Shaders/depth.vertex";
  56960. /**
  56961. * This represents a depth renderer in Babylon.
  56962. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56963. */
  56964. export class DepthRenderer {
  56965. private _scene;
  56966. private _depthMap;
  56967. private _effect;
  56968. private _cachedDefines;
  56969. private _camera;
  56970. /**
  56971. * Specifiess that the depth renderer will only be used within
  56972. * the camera it is created for.
  56973. * This can help forcing its rendering during the camera processing.
  56974. */
  56975. useOnlyInActiveCamera: boolean;
  56976. /** @hidden */
  56977. static _SceneComponentInitialization: (scene: Scene) => void;
  56978. /**
  56979. * Instantiates a depth renderer
  56980. * @param scene The scene the renderer belongs to
  56981. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56982. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56983. */
  56984. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  56985. /**
  56986. * Creates the depth rendering effect and checks if the effect is ready.
  56987. * @param subMesh The submesh to be used to render the depth map of
  56988. * @param useInstances If multiple world instances should be used
  56989. * @returns if the depth renderer is ready to render the depth map
  56990. */
  56991. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56992. /**
  56993. * Gets the texture which the depth map will be written to.
  56994. * @returns The depth map texture
  56995. */
  56996. getDepthMap(): RenderTargetTexture;
  56997. /**
  56998. * Disposes of the depth renderer.
  56999. */
  57000. dispose(): void;
  57001. }
  57002. }
  57003. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57004. import { Nullable } from "babylonjs/types";
  57005. import { Scene } from "babylonjs/scene";
  57006. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57007. import { Camera } from "babylonjs/Cameras/camera";
  57008. import { ISceneComponent } from "babylonjs/sceneComponent";
  57009. module "babylonjs/scene" {
  57010. interface Scene {
  57011. /** @hidden (Backing field) */
  57012. _depthRenderer: {
  57013. [id: string]: DepthRenderer;
  57014. };
  57015. /**
  57016. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57017. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57018. * @returns the created depth renderer
  57019. */
  57020. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57021. /**
  57022. * Disables a depth renderer for a given camera
  57023. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57024. */
  57025. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57026. }
  57027. }
  57028. /**
  57029. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57030. * in several rendering techniques.
  57031. */
  57032. export class DepthRendererSceneComponent implements ISceneComponent {
  57033. /**
  57034. * The component name helpfull to identify the component in the list of scene components.
  57035. */
  57036. readonly name: string;
  57037. /**
  57038. * The scene the component belongs to.
  57039. */
  57040. scene: Scene;
  57041. /**
  57042. * Creates a new instance of the component for the given scene
  57043. * @param scene Defines the scene to register the component in
  57044. */
  57045. constructor(scene: Scene);
  57046. /**
  57047. * Registers the component in a given scene
  57048. */
  57049. register(): void;
  57050. /**
  57051. * Rebuilds the elements related to this component in case of
  57052. * context lost for instance.
  57053. */
  57054. rebuild(): void;
  57055. /**
  57056. * Disposes the component and the associated ressources
  57057. */
  57058. dispose(): void;
  57059. private _gatherRenderTargets;
  57060. private _gatherActiveCameraRenderTargets;
  57061. }
  57062. }
  57063. declare module "babylonjs/Shaders/outline.fragment" {
  57064. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57065. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57066. /** @hidden */
  57067. export var outlinePixelShader: {
  57068. name: string;
  57069. shader: string;
  57070. };
  57071. }
  57072. declare module "babylonjs/Shaders/outline.vertex" {
  57073. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57074. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57075. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57076. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57077. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57078. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57079. /** @hidden */
  57080. export var outlineVertexShader: {
  57081. name: string;
  57082. shader: string;
  57083. };
  57084. }
  57085. declare module "babylonjs/Rendering/outlineRenderer" {
  57086. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57087. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57088. import { Scene } from "babylonjs/scene";
  57089. import { ISceneComponent } from "babylonjs/sceneComponent";
  57090. import "babylonjs/Shaders/outline.fragment";
  57091. import "babylonjs/Shaders/outline.vertex";
  57092. module "babylonjs/scene" {
  57093. interface Scene {
  57094. /** @hidden */
  57095. _outlineRenderer: OutlineRenderer;
  57096. /**
  57097. * Gets the outline renderer associated with the scene
  57098. * @returns a OutlineRenderer
  57099. */
  57100. getOutlineRenderer(): OutlineRenderer;
  57101. }
  57102. }
  57103. module "babylonjs/Meshes/abstractMesh" {
  57104. interface AbstractMesh {
  57105. /** @hidden (Backing field) */
  57106. _renderOutline: boolean;
  57107. /**
  57108. * Gets or sets a boolean indicating if the outline must be rendered as well
  57109. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57110. */
  57111. renderOutline: boolean;
  57112. /** @hidden (Backing field) */
  57113. _renderOverlay: boolean;
  57114. /**
  57115. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57116. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57117. */
  57118. renderOverlay: boolean;
  57119. }
  57120. }
  57121. /**
  57122. * This class is responsible to draw bothe outline/overlay of meshes.
  57123. * It should not be used directly but through the available method on mesh.
  57124. */
  57125. export class OutlineRenderer implements ISceneComponent {
  57126. /**
  57127. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57128. */
  57129. private static _StencilReference;
  57130. /**
  57131. * The name of the component. Each component must have a unique name.
  57132. */
  57133. name: string;
  57134. /**
  57135. * The scene the component belongs to.
  57136. */
  57137. scene: Scene;
  57138. /**
  57139. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57140. */
  57141. zOffset: number;
  57142. private _engine;
  57143. private _effect;
  57144. private _cachedDefines;
  57145. private _savedDepthWrite;
  57146. /**
  57147. * Instantiates a new outline renderer. (There could be only one per scene).
  57148. * @param scene Defines the scene it belongs to
  57149. */
  57150. constructor(scene: Scene);
  57151. /**
  57152. * Register the component to one instance of a scene.
  57153. */
  57154. register(): void;
  57155. /**
  57156. * Rebuilds the elements related to this component in case of
  57157. * context lost for instance.
  57158. */
  57159. rebuild(): void;
  57160. /**
  57161. * Disposes the component and the associated ressources.
  57162. */
  57163. dispose(): void;
  57164. /**
  57165. * Renders the outline in the canvas.
  57166. * @param subMesh Defines the sumesh to render
  57167. * @param batch Defines the batch of meshes in case of instances
  57168. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57169. */
  57170. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57171. /**
  57172. * Returns whether or not the outline renderer is ready for a given submesh.
  57173. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57174. * @param subMesh Defines the submesh to check readyness for
  57175. * @param useInstances Defines wheter wee are trying to render instances or not
  57176. * @returns true if ready otherwise false
  57177. */
  57178. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57179. private _beforeRenderingMesh;
  57180. private _afterRenderingMesh;
  57181. }
  57182. }
  57183. declare module "babylonjs/Rendering/index" {
  57184. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57185. export * from "babylonjs/Rendering/depthRenderer";
  57186. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57187. export * from "babylonjs/Rendering/edgesRenderer";
  57188. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57189. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57190. export * from "babylonjs/Rendering/outlineRenderer";
  57191. export * from "babylonjs/Rendering/renderingGroup";
  57192. export * from "babylonjs/Rendering/renderingManager";
  57193. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57194. }
  57195. declare module "babylonjs/Sprites/index" {
  57196. export * from "babylonjs/Sprites/sprite";
  57197. export * from "babylonjs/Sprites/spriteManager";
  57198. export * from "babylonjs/Sprites/spriteSceneComponent";
  57199. }
  57200. declare module "babylonjs/Misc/assetsManager" {
  57201. import { Scene } from "babylonjs/scene";
  57202. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57203. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57204. import { Skeleton } from "babylonjs/Bones/skeleton";
  57205. import { Observable } from "babylonjs/Misc/observable";
  57206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57207. import { Texture } from "babylonjs/Materials/Textures/texture";
  57208. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57209. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57210. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57211. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57212. /**
  57213. * Defines the list of states available for a task inside a AssetsManager
  57214. */
  57215. export enum AssetTaskState {
  57216. /**
  57217. * Initialization
  57218. */
  57219. INIT = 0,
  57220. /**
  57221. * Running
  57222. */
  57223. RUNNING = 1,
  57224. /**
  57225. * Done
  57226. */
  57227. DONE = 2,
  57228. /**
  57229. * Error
  57230. */
  57231. ERROR = 3
  57232. }
  57233. /**
  57234. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57235. */
  57236. export abstract class AbstractAssetTask {
  57237. /**
  57238. * Task name
  57239. */ name: string;
  57240. /**
  57241. * Callback called when the task is successful
  57242. */
  57243. onSuccess: (task: any) => void;
  57244. /**
  57245. * Callback called when the task is not successful
  57246. */
  57247. onError: (task: any, message?: string, exception?: any) => void;
  57248. /**
  57249. * Creates a new AssetsManager
  57250. * @param name defines the name of the task
  57251. */
  57252. constructor(
  57253. /**
  57254. * Task name
  57255. */ name: string);
  57256. private _isCompleted;
  57257. private _taskState;
  57258. private _errorObject;
  57259. /**
  57260. * Get if the task is completed
  57261. */
  57262. readonly isCompleted: boolean;
  57263. /**
  57264. * Gets the current state of the task
  57265. */
  57266. readonly taskState: AssetTaskState;
  57267. /**
  57268. * Gets the current error object (if task is in error)
  57269. */
  57270. readonly errorObject: {
  57271. message?: string;
  57272. exception?: any;
  57273. };
  57274. /**
  57275. * Internal only
  57276. * @hidden
  57277. */
  57278. _setErrorObject(message?: string, exception?: any): void;
  57279. /**
  57280. * Execute the current task
  57281. * @param scene defines the scene where you want your assets to be loaded
  57282. * @param onSuccess is a callback called when the task is successfully executed
  57283. * @param onError is a callback called if an error occurs
  57284. */
  57285. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57286. /**
  57287. * Execute the current task
  57288. * @param scene defines the scene where you want your assets to be loaded
  57289. * @param onSuccess is a callback called when the task is successfully executed
  57290. * @param onError is a callback called if an error occurs
  57291. */
  57292. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57293. /**
  57294. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57295. * This can be used with failed tasks that have the reason for failure fixed.
  57296. */
  57297. reset(): void;
  57298. private onErrorCallback;
  57299. private onDoneCallback;
  57300. }
  57301. /**
  57302. * Define the interface used by progress events raised during assets loading
  57303. */
  57304. export interface IAssetsProgressEvent {
  57305. /**
  57306. * Defines the number of remaining tasks to process
  57307. */
  57308. remainingCount: number;
  57309. /**
  57310. * Defines the total number of tasks
  57311. */
  57312. totalCount: number;
  57313. /**
  57314. * Defines the task that was just processed
  57315. */
  57316. task: AbstractAssetTask;
  57317. }
  57318. /**
  57319. * Class used to share progress information about assets loading
  57320. */
  57321. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57322. /**
  57323. * Defines the number of remaining tasks to process
  57324. */
  57325. remainingCount: number;
  57326. /**
  57327. * Defines the total number of tasks
  57328. */
  57329. totalCount: number;
  57330. /**
  57331. * Defines the task that was just processed
  57332. */
  57333. task: AbstractAssetTask;
  57334. /**
  57335. * Creates a AssetsProgressEvent
  57336. * @param remainingCount defines the number of remaining tasks to process
  57337. * @param totalCount defines the total number of tasks
  57338. * @param task defines the task that was just processed
  57339. */
  57340. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57341. }
  57342. /**
  57343. * Define a task used by AssetsManager to load meshes
  57344. */
  57345. export class MeshAssetTask extends AbstractAssetTask {
  57346. /**
  57347. * Defines the name of the task
  57348. */
  57349. name: string;
  57350. /**
  57351. * Defines the list of mesh's names you want to load
  57352. */
  57353. meshesNames: any;
  57354. /**
  57355. * Defines the root url to use as a base to load your meshes and associated resources
  57356. */
  57357. rootUrl: string;
  57358. /**
  57359. * Defines the filename of the scene to load from
  57360. */
  57361. sceneFilename: string;
  57362. /**
  57363. * Gets the list of loaded meshes
  57364. */
  57365. loadedMeshes: Array<AbstractMesh>;
  57366. /**
  57367. * Gets the list of loaded particle systems
  57368. */
  57369. loadedParticleSystems: Array<IParticleSystem>;
  57370. /**
  57371. * Gets the list of loaded skeletons
  57372. */
  57373. loadedSkeletons: Array<Skeleton>;
  57374. /**
  57375. * Gets the list of loaded animation groups
  57376. */
  57377. loadedAnimationGroups: Array<AnimationGroup>;
  57378. /**
  57379. * Callback called when the task is successful
  57380. */
  57381. onSuccess: (task: MeshAssetTask) => void;
  57382. /**
  57383. * Callback called when the task is successful
  57384. */
  57385. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57386. /**
  57387. * Creates a new MeshAssetTask
  57388. * @param name defines the name of the task
  57389. * @param meshesNames defines the list of mesh's names you want to load
  57390. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57391. * @param sceneFilename defines the filename of the scene to load from
  57392. */
  57393. constructor(
  57394. /**
  57395. * Defines the name of the task
  57396. */
  57397. name: string,
  57398. /**
  57399. * Defines the list of mesh's names you want to load
  57400. */
  57401. meshesNames: any,
  57402. /**
  57403. * Defines the root url to use as a base to load your meshes and associated resources
  57404. */
  57405. rootUrl: string,
  57406. /**
  57407. * Defines the filename of the scene to load from
  57408. */
  57409. sceneFilename: string);
  57410. /**
  57411. * Execute the current task
  57412. * @param scene defines the scene where you want your assets to be loaded
  57413. * @param onSuccess is a callback called when the task is successfully executed
  57414. * @param onError is a callback called if an error occurs
  57415. */
  57416. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57417. }
  57418. /**
  57419. * Define a task used by AssetsManager to load text content
  57420. */
  57421. export class TextFileAssetTask extends AbstractAssetTask {
  57422. /**
  57423. * Defines the name of the task
  57424. */
  57425. name: string;
  57426. /**
  57427. * Defines the location of the file to load
  57428. */
  57429. url: string;
  57430. /**
  57431. * Gets the loaded text string
  57432. */
  57433. text: string;
  57434. /**
  57435. * Callback called when the task is successful
  57436. */
  57437. onSuccess: (task: TextFileAssetTask) => void;
  57438. /**
  57439. * Callback called when the task is successful
  57440. */
  57441. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57442. /**
  57443. * Creates a new TextFileAssetTask object
  57444. * @param name defines the name of the task
  57445. * @param url defines the location of the file to load
  57446. */
  57447. constructor(
  57448. /**
  57449. * Defines the name of the task
  57450. */
  57451. name: string,
  57452. /**
  57453. * Defines the location of the file to load
  57454. */
  57455. url: string);
  57456. /**
  57457. * Execute the current task
  57458. * @param scene defines the scene where you want your assets to be loaded
  57459. * @param onSuccess is a callback called when the task is successfully executed
  57460. * @param onError is a callback called if an error occurs
  57461. */
  57462. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57463. }
  57464. /**
  57465. * Define a task used by AssetsManager to load binary data
  57466. */
  57467. export class BinaryFileAssetTask extends AbstractAssetTask {
  57468. /**
  57469. * Defines the name of the task
  57470. */
  57471. name: string;
  57472. /**
  57473. * Defines the location of the file to load
  57474. */
  57475. url: string;
  57476. /**
  57477. * Gets the lodaded data (as an array buffer)
  57478. */
  57479. data: ArrayBuffer;
  57480. /**
  57481. * Callback called when the task is successful
  57482. */
  57483. onSuccess: (task: BinaryFileAssetTask) => void;
  57484. /**
  57485. * Callback called when the task is successful
  57486. */
  57487. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57488. /**
  57489. * Creates a new BinaryFileAssetTask object
  57490. * @param name defines the name of the new task
  57491. * @param url defines the location of the file to load
  57492. */
  57493. constructor(
  57494. /**
  57495. * Defines the name of the task
  57496. */
  57497. name: string,
  57498. /**
  57499. * Defines the location of the file to load
  57500. */
  57501. url: string);
  57502. /**
  57503. * Execute the current task
  57504. * @param scene defines the scene where you want your assets to be loaded
  57505. * @param onSuccess is a callback called when the task is successfully executed
  57506. * @param onError is a callback called if an error occurs
  57507. */
  57508. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57509. }
  57510. /**
  57511. * Define a task used by AssetsManager to load images
  57512. */
  57513. export class ImageAssetTask extends AbstractAssetTask {
  57514. /**
  57515. * Defines the name of the task
  57516. */
  57517. name: string;
  57518. /**
  57519. * Defines the location of the image to load
  57520. */
  57521. url: string;
  57522. /**
  57523. * Gets the loaded images
  57524. */
  57525. image: HTMLImageElement;
  57526. /**
  57527. * Callback called when the task is successful
  57528. */
  57529. onSuccess: (task: ImageAssetTask) => void;
  57530. /**
  57531. * Callback called when the task is successful
  57532. */
  57533. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57534. /**
  57535. * Creates a new ImageAssetTask
  57536. * @param name defines the name of the task
  57537. * @param url defines the location of the image to load
  57538. */
  57539. constructor(
  57540. /**
  57541. * Defines the name of the task
  57542. */
  57543. name: string,
  57544. /**
  57545. * Defines the location of the image to load
  57546. */
  57547. url: string);
  57548. /**
  57549. * Execute the current task
  57550. * @param scene defines the scene where you want your assets to be loaded
  57551. * @param onSuccess is a callback called when the task is successfully executed
  57552. * @param onError is a callback called if an error occurs
  57553. */
  57554. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57555. }
  57556. /**
  57557. * Defines the interface used by texture loading tasks
  57558. */
  57559. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57560. /**
  57561. * Gets the loaded texture
  57562. */
  57563. texture: TEX;
  57564. }
  57565. /**
  57566. * Define a task used by AssetsManager to load 2D textures
  57567. */
  57568. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57569. /**
  57570. * Defines the name of the task
  57571. */
  57572. name: string;
  57573. /**
  57574. * Defines the location of the file to load
  57575. */
  57576. url: string;
  57577. /**
  57578. * Defines if mipmap should not be generated (default is false)
  57579. */
  57580. noMipmap?: boolean | undefined;
  57581. /**
  57582. * Defines if texture must be inverted on Y axis (default is false)
  57583. */
  57584. invertY?: boolean | undefined;
  57585. /**
  57586. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57587. */
  57588. samplingMode: number;
  57589. /**
  57590. * Gets the loaded texture
  57591. */
  57592. texture: Texture;
  57593. /**
  57594. * Callback called when the task is successful
  57595. */
  57596. onSuccess: (task: TextureAssetTask) => void;
  57597. /**
  57598. * Callback called when the task is successful
  57599. */
  57600. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57601. /**
  57602. * Creates a new TextureAssetTask object
  57603. * @param name defines the name of the task
  57604. * @param url defines the location of the file to load
  57605. * @param noMipmap defines if mipmap should not be generated (default is false)
  57606. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57607. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57608. */
  57609. constructor(
  57610. /**
  57611. * Defines the name of the task
  57612. */
  57613. name: string,
  57614. /**
  57615. * Defines the location of the file to load
  57616. */
  57617. url: string,
  57618. /**
  57619. * Defines if mipmap should not be generated (default is false)
  57620. */
  57621. noMipmap?: boolean | undefined,
  57622. /**
  57623. * Defines if texture must be inverted on Y axis (default is false)
  57624. */
  57625. invertY?: boolean | undefined,
  57626. /**
  57627. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57628. */
  57629. samplingMode?: number);
  57630. /**
  57631. * Execute the current task
  57632. * @param scene defines the scene where you want your assets to be loaded
  57633. * @param onSuccess is a callback called when the task is successfully executed
  57634. * @param onError is a callback called if an error occurs
  57635. */
  57636. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57637. }
  57638. /**
  57639. * Define a task used by AssetsManager to load cube textures
  57640. */
  57641. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57642. /**
  57643. * Defines the name of the task
  57644. */
  57645. name: string;
  57646. /**
  57647. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57648. */
  57649. url: string;
  57650. /**
  57651. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57652. */
  57653. extensions?: string[] | undefined;
  57654. /**
  57655. * Defines if mipmaps should not be generated (default is false)
  57656. */
  57657. noMipmap?: boolean | undefined;
  57658. /**
  57659. * Defines the explicit list of files (undefined by default)
  57660. */
  57661. files?: string[] | undefined;
  57662. /**
  57663. * Gets the loaded texture
  57664. */
  57665. texture: CubeTexture;
  57666. /**
  57667. * Callback called when the task is successful
  57668. */
  57669. onSuccess: (task: CubeTextureAssetTask) => void;
  57670. /**
  57671. * Callback called when the task is successful
  57672. */
  57673. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57674. /**
  57675. * Creates a new CubeTextureAssetTask
  57676. * @param name defines the name of the task
  57677. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57678. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57679. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57680. * @param files defines the explicit list of files (undefined by default)
  57681. */
  57682. constructor(
  57683. /**
  57684. * Defines the name of the task
  57685. */
  57686. name: string,
  57687. /**
  57688. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57689. */
  57690. url: string,
  57691. /**
  57692. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57693. */
  57694. extensions?: string[] | undefined,
  57695. /**
  57696. * Defines if mipmaps should not be generated (default is false)
  57697. */
  57698. noMipmap?: boolean | undefined,
  57699. /**
  57700. * Defines the explicit list of files (undefined by default)
  57701. */
  57702. files?: string[] | undefined);
  57703. /**
  57704. * Execute the current task
  57705. * @param scene defines the scene where you want your assets to be loaded
  57706. * @param onSuccess is a callback called when the task is successfully executed
  57707. * @param onError is a callback called if an error occurs
  57708. */
  57709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57710. }
  57711. /**
  57712. * Define a task used by AssetsManager to load HDR cube textures
  57713. */
  57714. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57715. /**
  57716. * Defines the name of the task
  57717. */
  57718. name: string;
  57719. /**
  57720. * Defines the location of the file to load
  57721. */
  57722. url: string;
  57723. /**
  57724. * Defines the desired size (the more it increases the longer the generation will be)
  57725. */
  57726. size: number;
  57727. /**
  57728. * Defines if mipmaps should not be generated (default is false)
  57729. */
  57730. noMipmap: boolean;
  57731. /**
  57732. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57733. */
  57734. generateHarmonics: boolean;
  57735. /**
  57736. * 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)
  57737. */
  57738. gammaSpace: boolean;
  57739. /**
  57740. * Internal Use Only
  57741. */
  57742. reserved: boolean;
  57743. /**
  57744. * Gets the loaded texture
  57745. */
  57746. texture: HDRCubeTexture;
  57747. /**
  57748. * Callback called when the task is successful
  57749. */
  57750. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57751. /**
  57752. * Callback called when the task is successful
  57753. */
  57754. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57755. /**
  57756. * Creates a new HDRCubeTextureAssetTask object
  57757. * @param name defines the name of the task
  57758. * @param url defines the location of the file to load
  57759. * @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.
  57760. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57761. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57762. * @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)
  57763. * @param reserved Internal use only
  57764. */
  57765. constructor(
  57766. /**
  57767. * Defines the name of the task
  57768. */
  57769. name: string,
  57770. /**
  57771. * Defines the location of the file to load
  57772. */
  57773. url: string,
  57774. /**
  57775. * Defines the desired size (the more it increases the longer the generation will be)
  57776. */
  57777. size: number,
  57778. /**
  57779. * Defines if mipmaps should not be generated (default is false)
  57780. */
  57781. noMipmap?: boolean,
  57782. /**
  57783. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57784. */
  57785. generateHarmonics?: boolean,
  57786. /**
  57787. * 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)
  57788. */
  57789. gammaSpace?: boolean,
  57790. /**
  57791. * Internal Use Only
  57792. */
  57793. reserved?: boolean);
  57794. /**
  57795. * Execute the current task
  57796. * @param scene defines the scene where you want your assets to be loaded
  57797. * @param onSuccess is a callback called when the task is successfully executed
  57798. * @param onError is a callback called if an error occurs
  57799. */
  57800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57801. }
  57802. /**
  57803. * Define a task used by AssetsManager to load Equirectangular cube textures
  57804. */
  57805. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57806. /**
  57807. * Defines the name of the task
  57808. */
  57809. name: string;
  57810. /**
  57811. * Defines the location of the file to load
  57812. */
  57813. url: string;
  57814. /**
  57815. * Defines the desired size (the more it increases the longer the generation will be)
  57816. */
  57817. size: number;
  57818. /**
  57819. * Defines if mipmaps should not be generated (default is false)
  57820. */
  57821. noMipmap: boolean;
  57822. /**
  57823. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57824. * but the standard material would require them in Gamma space) (default is true)
  57825. */
  57826. gammaSpace: boolean;
  57827. /**
  57828. * Gets the loaded texture
  57829. */
  57830. texture: EquiRectangularCubeTexture;
  57831. /**
  57832. * Callback called when the task is successful
  57833. */
  57834. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57835. /**
  57836. * Callback called when the task is successful
  57837. */
  57838. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57839. /**
  57840. * Creates a new EquiRectangularCubeTextureAssetTask object
  57841. * @param name defines the name of the task
  57842. * @param url defines the location of the file to load
  57843. * @param size defines the desired size (the more it increases the longer the generation will be)
  57844. * If the size is omitted this implies you are using a preprocessed cubemap.
  57845. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57846. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57847. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57848. * (default is true)
  57849. */
  57850. constructor(
  57851. /**
  57852. * Defines the name of the task
  57853. */
  57854. name: string,
  57855. /**
  57856. * Defines the location of the file to load
  57857. */
  57858. url: string,
  57859. /**
  57860. * Defines the desired size (the more it increases the longer the generation will be)
  57861. */
  57862. size: number,
  57863. /**
  57864. * Defines if mipmaps should not be generated (default is false)
  57865. */
  57866. noMipmap?: boolean,
  57867. /**
  57868. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57869. * but the standard material would require them in Gamma space) (default is true)
  57870. */
  57871. gammaSpace?: boolean);
  57872. /**
  57873. * Execute the current task
  57874. * @param scene defines the scene where you want your assets to be loaded
  57875. * @param onSuccess is a callback called when the task is successfully executed
  57876. * @param onError is a callback called if an error occurs
  57877. */
  57878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57879. }
  57880. /**
  57881. * This class can be used to easily import assets into a scene
  57882. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  57883. */
  57884. export class AssetsManager {
  57885. private _scene;
  57886. private _isLoading;
  57887. protected _tasks: AbstractAssetTask[];
  57888. protected _waitingTasksCount: number;
  57889. protected _totalTasksCount: number;
  57890. /**
  57891. * Callback called when all tasks are processed
  57892. */
  57893. onFinish: (tasks: AbstractAssetTask[]) => void;
  57894. /**
  57895. * Callback called when a task is successful
  57896. */
  57897. onTaskSuccess: (task: AbstractAssetTask) => void;
  57898. /**
  57899. * Callback called when a task had an error
  57900. */
  57901. onTaskError: (task: AbstractAssetTask) => void;
  57902. /**
  57903. * Callback called when a task is done (whatever the result is)
  57904. */
  57905. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  57906. /**
  57907. * Observable called when all tasks are processed
  57908. */
  57909. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  57910. /**
  57911. * Observable called when a task had an error
  57912. */
  57913. onTaskErrorObservable: Observable<AbstractAssetTask>;
  57914. /**
  57915. * Observable called when all tasks were executed
  57916. */
  57917. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  57918. /**
  57919. * Observable called when a task is done (whatever the result is)
  57920. */
  57921. onProgressObservable: Observable<IAssetsProgressEvent>;
  57922. /**
  57923. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  57924. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  57925. */
  57926. useDefaultLoadingScreen: boolean;
  57927. /**
  57928. * Creates a new AssetsManager
  57929. * @param scene defines the scene to work on
  57930. */
  57931. constructor(scene: Scene);
  57932. /**
  57933. * Add a MeshAssetTask to the list of active tasks
  57934. * @param taskName defines the name of the new task
  57935. * @param meshesNames defines the name of meshes to load
  57936. * @param rootUrl defines the root url to use to locate files
  57937. * @param sceneFilename defines the filename of the scene file
  57938. * @returns a new MeshAssetTask object
  57939. */
  57940. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  57941. /**
  57942. * Add a TextFileAssetTask to the list of active tasks
  57943. * @param taskName defines the name of the new task
  57944. * @param url defines the url of the file to load
  57945. * @returns a new TextFileAssetTask object
  57946. */
  57947. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  57948. /**
  57949. * Add a BinaryFileAssetTask to the list of active tasks
  57950. * @param taskName defines the name of the new task
  57951. * @param url defines the url of the file to load
  57952. * @returns a new BinaryFileAssetTask object
  57953. */
  57954. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  57955. /**
  57956. * Add a ImageAssetTask to the list of active tasks
  57957. * @param taskName defines the name of the new task
  57958. * @param url defines the url of the file to load
  57959. * @returns a new ImageAssetTask object
  57960. */
  57961. addImageTask(taskName: string, url: string): ImageAssetTask;
  57962. /**
  57963. * Add a TextureAssetTask to the list of active tasks
  57964. * @param taskName defines the name of the new task
  57965. * @param url defines the url of the file to load
  57966. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57967. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  57968. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57969. * @returns a new TextureAssetTask object
  57970. */
  57971. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  57972. /**
  57973. * Add a CubeTextureAssetTask to the list of active tasks
  57974. * @param taskName defines the name of the new task
  57975. * @param url defines the url of the file to load
  57976. * @param extensions defines the extension to use to load the cube map (can be null)
  57977. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57978. * @param files defines the list of files to load (can be null)
  57979. * @returns a new CubeTextureAssetTask object
  57980. */
  57981. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  57982. /**
  57983. *
  57984. * Add a HDRCubeTextureAssetTask to the list of active tasks
  57985. * @param taskName defines the name of the new task
  57986. * @param url defines the url of the file to load
  57987. * @param size defines the size you want for the cubemap (can be null)
  57988. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  57989. * @param generateHarmonics defines if you want to automatically generate (true by default)
  57990. * @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)
  57991. * @param reserved Internal use only
  57992. * @returns a new HDRCubeTextureAssetTask object
  57993. */
  57994. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  57995. /**
  57996. *
  57997. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  57998. * @param taskName defines the name of the new task
  57999. * @param url defines the url of the file to load
  58000. * @param size defines the size you want for the cubemap (can be null)
  58001. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58002. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58003. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58004. * @returns a new EquiRectangularCubeTextureAssetTask object
  58005. */
  58006. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58007. /**
  58008. * Remove a task from the assets manager.
  58009. * @param task the task to remove
  58010. */
  58011. removeTask(task: AbstractAssetTask): void;
  58012. private _decreaseWaitingTasksCount;
  58013. private _runTask;
  58014. /**
  58015. * Reset the AssetsManager and remove all tasks
  58016. * @return the current instance of the AssetsManager
  58017. */
  58018. reset(): AssetsManager;
  58019. /**
  58020. * Start the loading process
  58021. * @return the current instance of the AssetsManager
  58022. */
  58023. load(): AssetsManager;
  58024. /**
  58025. * Start the loading process as an async operation
  58026. * @return a promise returning the list of failed tasks
  58027. */
  58028. loadAsync(): Promise<void>;
  58029. }
  58030. }
  58031. declare module "babylonjs/Misc/deferred" {
  58032. /**
  58033. * Wrapper class for promise with external resolve and reject.
  58034. */
  58035. export class Deferred<T> {
  58036. /**
  58037. * The promise associated with this deferred object.
  58038. */
  58039. readonly promise: Promise<T>;
  58040. private _resolve;
  58041. private _reject;
  58042. /**
  58043. * The resolve method of the promise associated with this deferred object.
  58044. */
  58045. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58046. /**
  58047. * The reject method of the promise associated with this deferred object.
  58048. */
  58049. readonly reject: (reason?: any) => void;
  58050. /**
  58051. * Constructor for this deferred object.
  58052. */
  58053. constructor();
  58054. }
  58055. }
  58056. declare module "babylonjs/Misc/meshExploder" {
  58057. import { Mesh } from "babylonjs/Meshes/mesh";
  58058. /**
  58059. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58060. */
  58061. export class MeshExploder {
  58062. private _centerMesh;
  58063. private _meshes;
  58064. private _meshesOrigins;
  58065. private _toCenterVectors;
  58066. private _scaledDirection;
  58067. private _newPosition;
  58068. private _centerPosition;
  58069. /**
  58070. * Explodes meshes from a center mesh.
  58071. * @param meshes The meshes to explode.
  58072. * @param centerMesh The mesh to be center of explosion.
  58073. */
  58074. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58075. private _setCenterMesh;
  58076. /**
  58077. * Get class name
  58078. * @returns "MeshExploder"
  58079. */
  58080. getClassName(): string;
  58081. /**
  58082. * "Exploded meshes"
  58083. * @returns Array of meshes with the centerMesh at index 0.
  58084. */
  58085. getMeshes(): Array<Mesh>;
  58086. /**
  58087. * Explodes meshes giving a specific direction
  58088. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58089. */
  58090. explode(direction?: number): void;
  58091. }
  58092. }
  58093. declare module "babylonjs/Misc/filesInput" {
  58094. import { Engine } from "babylonjs/Engines/engine";
  58095. import { Scene } from "babylonjs/scene";
  58096. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58097. /**
  58098. * Class used to help managing file picking and drag'n'drop
  58099. */
  58100. export class FilesInput {
  58101. /**
  58102. * List of files ready to be loaded
  58103. */
  58104. static readonly FilesToLoad: {
  58105. [key: string]: File;
  58106. };
  58107. /**
  58108. * Callback called when a file is processed
  58109. */
  58110. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58111. private _engine;
  58112. private _currentScene;
  58113. private _sceneLoadedCallback;
  58114. private _progressCallback;
  58115. private _additionalRenderLoopLogicCallback;
  58116. private _textureLoadingCallback;
  58117. private _startingProcessingFilesCallback;
  58118. private _onReloadCallback;
  58119. private _errorCallback;
  58120. private _elementToMonitor;
  58121. private _sceneFileToLoad;
  58122. private _filesToLoad;
  58123. /**
  58124. * Creates a new FilesInput
  58125. * @param engine defines the rendering engine
  58126. * @param scene defines the hosting scene
  58127. * @param sceneLoadedCallback callback called when scene is loaded
  58128. * @param progressCallback callback called to track progress
  58129. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58130. * @param textureLoadingCallback callback called when a texture is loading
  58131. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58132. * @param onReloadCallback callback called when a reload is requested
  58133. * @param errorCallback callback call if an error occurs
  58134. */
  58135. 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);
  58136. private _dragEnterHandler;
  58137. private _dragOverHandler;
  58138. private _dropHandler;
  58139. /**
  58140. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58141. * @param elementToMonitor defines the DOM element to track
  58142. */
  58143. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58144. /**
  58145. * Release all associated resources
  58146. */
  58147. dispose(): void;
  58148. private renderFunction;
  58149. private drag;
  58150. private drop;
  58151. private _traverseFolder;
  58152. private _processFiles;
  58153. /**
  58154. * Load files from a drop event
  58155. * @param event defines the drop event to use as source
  58156. */
  58157. loadFiles(event: any): void;
  58158. private _processReload;
  58159. /**
  58160. * Reload the current scene from the loaded files
  58161. */
  58162. reload(): void;
  58163. }
  58164. }
  58165. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58166. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58167. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58168. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58169. }
  58170. declare module "babylonjs/Misc/sceneOptimizer" {
  58171. import { Scene, IDisposable } from "babylonjs/scene";
  58172. import { Observable } from "babylonjs/Misc/observable";
  58173. /**
  58174. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58175. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58176. */
  58177. export class SceneOptimization {
  58178. /**
  58179. * Defines the priority of this optimization (0 by default which means first in the list)
  58180. */
  58181. priority: number;
  58182. /**
  58183. * Gets a string describing the action executed by the current optimization
  58184. * @returns description string
  58185. */
  58186. getDescription(): string;
  58187. /**
  58188. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58189. * @param scene defines the current scene where to apply this optimization
  58190. * @param optimizer defines the current optimizer
  58191. * @returns true if everything that can be done was applied
  58192. */
  58193. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58194. /**
  58195. * Creates the SceneOptimization object
  58196. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58197. * @param desc defines the description associated with the optimization
  58198. */
  58199. constructor(
  58200. /**
  58201. * Defines the priority of this optimization (0 by default which means first in the list)
  58202. */
  58203. priority?: number);
  58204. }
  58205. /**
  58206. * Defines an optimization used to reduce the size of render target textures
  58207. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58208. */
  58209. export class TextureOptimization extends SceneOptimization {
  58210. /**
  58211. * Defines the priority of this optimization (0 by default which means first in the list)
  58212. */
  58213. priority: number;
  58214. /**
  58215. * 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
  58216. */
  58217. maximumSize: number;
  58218. /**
  58219. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58220. */
  58221. step: number;
  58222. /**
  58223. * Gets a string describing the action executed by the current optimization
  58224. * @returns description string
  58225. */
  58226. getDescription(): string;
  58227. /**
  58228. * Creates the TextureOptimization object
  58229. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58230. * @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
  58231. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58232. */
  58233. constructor(
  58234. /**
  58235. * Defines the priority of this optimization (0 by default which means first in the list)
  58236. */
  58237. priority?: number,
  58238. /**
  58239. * 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
  58240. */
  58241. maximumSize?: number,
  58242. /**
  58243. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58244. */
  58245. step?: number);
  58246. /**
  58247. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58248. * @param scene defines the current scene where to apply this optimization
  58249. * @param optimizer defines the current optimizer
  58250. * @returns true if everything that can be done was applied
  58251. */
  58252. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58253. }
  58254. /**
  58255. * Defines an optimization used to increase or decrease the rendering resolution
  58256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58257. */
  58258. export class HardwareScalingOptimization extends SceneOptimization {
  58259. /**
  58260. * Defines the priority of this optimization (0 by default which means first in the list)
  58261. */
  58262. priority: number;
  58263. /**
  58264. * Defines the maximum scale to use (2 by default)
  58265. */
  58266. maximumScale: number;
  58267. /**
  58268. * Defines the step to use between two passes (0.5 by default)
  58269. */
  58270. step: number;
  58271. private _currentScale;
  58272. private _directionOffset;
  58273. /**
  58274. * Gets a string describing the action executed by the current optimization
  58275. * @return description string
  58276. */
  58277. getDescription(): string;
  58278. /**
  58279. * Creates the HardwareScalingOptimization object
  58280. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58281. * @param maximumScale defines the maximum scale to use (2 by default)
  58282. * @param step defines the step to use between two passes (0.5 by default)
  58283. */
  58284. constructor(
  58285. /**
  58286. * Defines the priority of this optimization (0 by default which means first in the list)
  58287. */
  58288. priority?: number,
  58289. /**
  58290. * Defines the maximum scale to use (2 by default)
  58291. */
  58292. maximumScale?: number,
  58293. /**
  58294. * Defines the step to use between two passes (0.5 by default)
  58295. */
  58296. step?: number);
  58297. /**
  58298. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58299. * @param scene defines the current scene where to apply this optimization
  58300. * @param optimizer defines the current optimizer
  58301. * @returns true if everything that can be done was applied
  58302. */
  58303. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58304. }
  58305. /**
  58306. * Defines an optimization used to remove shadows
  58307. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58308. */
  58309. export class ShadowsOptimization extends SceneOptimization {
  58310. /**
  58311. * Gets a string describing the action executed by the current optimization
  58312. * @return description string
  58313. */
  58314. getDescription(): string;
  58315. /**
  58316. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58317. * @param scene defines the current scene where to apply this optimization
  58318. * @param optimizer defines the current optimizer
  58319. * @returns true if everything that can be done was applied
  58320. */
  58321. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58322. }
  58323. /**
  58324. * Defines an optimization used to turn post-processes off
  58325. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58326. */
  58327. export class PostProcessesOptimization extends SceneOptimization {
  58328. /**
  58329. * Gets a string describing the action executed by the current optimization
  58330. * @return description string
  58331. */
  58332. getDescription(): string;
  58333. /**
  58334. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58335. * @param scene defines the current scene where to apply this optimization
  58336. * @param optimizer defines the current optimizer
  58337. * @returns true if everything that can be done was applied
  58338. */
  58339. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58340. }
  58341. /**
  58342. * Defines an optimization used to turn lens flares off
  58343. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58344. */
  58345. export class LensFlaresOptimization extends SceneOptimization {
  58346. /**
  58347. * Gets a string describing the action executed by the current optimization
  58348. * @return description string
  58349. */
  58350. getDescription(): string;
  58351. /**
  58352. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58353. * @param scene defines the current scene where to apply this optimization
  58354. * @param optimizer defines the current optimizer
  58355. * @returns true if everything that can be done was applied
  58356. */
  58357. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58358. }
  58359. /**
  58360. * Defines an optimization based on user defined callback.
  58361. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58362. */
  58363. export class CustomOptimization extends SceneOptimization {
  58364. /**
  58365. * Callback called to apply the custom optimization.
  58366. */
  58367. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58368. /**
  58369. * Callback called to get custom description
  58370. */
  58371. onGetDescription: () => string;
  58372. /**
  58373. * Gets a string describing the action executed by the current optimization
  58374. * @returns description string
  58375. */
  58376. getDescription(): string;
  58377. /**
  58378. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58379. * @param scene defines the current scene where to apply this optimization
  58380. * @param optimizer defines the current optimizer
  58381. * @returns true if everything that can be done was applied
  58382. */
  58383. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58384. }
  58385. /**
  58386. * Defines an optimization used to turn particles off
  58387. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58388. */
  58389. export class ParticlesOptimization extends SceneOptimization {
  58390. /**
  58391. * Gets a string describing the action executed by the current optimization
  58392. * @return description string
  58393. */
  58394. getDescription(): string;
  58395. /**
  58396. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58397. * @param scene defines the current scene where to apply this optimization
  58398. * @param optimizer defines the current optimizer
  58399. * @returns true if everything that can be done was applied
  58400. */
  58401. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58402. }
  58403. /**
  58404. * Defines an optimization used to turn render targets off
  58405. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58406. */
  58407. export class RenderTargetsOptimization extends SceneOptimization {
  58408. /**
  58409. * Gets a string describing the action executed by the current optimization
  58410. * @return description string
  58411. */
  58412. getDescription(): string;
  58413. /**
  58414. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58415. * @param scene defines the current scene where to apply this optimization
  58416. * @param optimizer defines the current optimizer
  58417. * @returns true if everything that can be done was applied
  58418. */
  58419. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58420. }
  58421. /**
  58422. * Defines an optimization used to merge meshes with compatible materials
  58423. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58424. */
  58425. export class MergeMeshesOptimization extends SceneOptimization {
  58426. private static _UpdateSelectionTree;
  58427. /**
  58428. * Gets or sets a boolean which defines if optimization octree has to be updated
  58429. */
  58430. /**
  58431. * Gets or sets a boolean which defines if optimization octree has to be updated
  58432. */
  58433. static UpdateSelectionTree: boolean;
  58434. /**
  58435. * Gets a string describing the action executed by the current optimization
  58436. * @return description string
  58437. */
  58438. getDescription(): string;
  58439. private _canBeMerged;
  58440. /**
  58441. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58442. * @param scene defines the current scene where to apply this optimization
  58443. * @param optimizer defines the current optimizer
  58444. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58445. * @returns true if everything that can be done was applied
  58446. */
  58447. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58448. }
  58449. /**
  58450. * Defines a list of options used by SceneOptimizer
  58451. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58452. */
  58453. export class SceneOptimizerOptions {
  58454. /**
  58455. * Defines the target frame rate to reach (60 by default)
  58456. */
  58457. targetFrameRate: number;
  58458. /**
  58459. * Defines the interval between two checkes (2000ms by default)
  58460. */
  58461. trackerDuration: number;
  58462. /**
  58463. * Gets the list of optimizations to apply
  58464. */
  58465. optimizations: SceneOptimization[];
  58466. /**
  58467. * Creates a new list of options used by SceneOptimizer
  58468. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58469. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58470. */
  58471. constructor(
  58472. /**
  58473. * Defines the target frame rate to reach (60 by default)
  58474. */
  58475. targetFrameRate?: number,
  58476. /**
  58477. * Defines the interval between two checkes (2000ms by default)
  58478. */
  58479. trackerDuration?: number);
  58480. /**
  58481. * Add a new optimization
  58482. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58483. * @returns the current SceneOptimizerOptions
  58484. */
  58485. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58486. /**
  58487. * Add a new custom optimization
  58488. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58489. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58490. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58491. * @returns the current SceneOptimizerOptions
  58492. */
  58493. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58494. /**
  58495. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58496. * @param targetFrameRate defines the target frame rate (60 by default)
  58497. * @returns a SceneOptimizerOptions object
  58498. */
  58499. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58500. /**
  58501. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58502. * @param targetFrameRate defines the target frame rate (60 by default)
  58503. * @returns a SceneOptimizerOptions object
  58504. */
  58505. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58506. /**
  58507. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58508. * @param targetFrameRate defines the target frame rate (60 by default)
  58509. * @returns a SceneOptimizerOptions object
  58510. */
  58511. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58512. }
  58513. /**
  58514. * Class used to run optimizations in order to reach a target frame rate
  58515. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58516. */
  58517. export class SceneOptimizer implements IDisposable {
  58518. private _isRunning;
  58519. private _options;
  58520. private _scene;
  58521. private _currentPriorityLevel;
  58522. private _targetFrameRate;
  58523. private _trackerDuration;
  58524. private _currentFrameRate;
  58525. private _sceneDisposeObserver;
  58526. private _improvementMode;
  58527. /**
  58528. * Defines an observable called when the optimizer reaches the target frame rate
  58529. */
  58530. onSuccessObservable: Observable<SceneOptimizer>;
  58531. /**
  58532. * Defines an observable called when the optimizer enables an optimization
  58533. */
  58534. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58535. /**
  58536. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58537. */
  58538. onFailureObservable: Observable<SceneOptimizer>;
  58539. /**
  58540. * Gets a boolean indicating if the optimizer is in improvement mode
  58541. */
  58542. readonly isInImprovementMode: boolean;
  58543. /**
  58544. * Gets the current priority level (0 at start)
  58545. */
  58546. readonly currentPriorityLevel: number;
  58547. /**
  58548. * Gets the current frame rate checked by the SceneOptimizer
  58549. */
  58550. readonly currentFrameRate: number;
  58551. /**
  58552. * Gets or sets the current target frame rate (60 by default)
  58553. */
  58554. /**
  58555. * Gets or sets the current target frame rate (60 by default)
  58556. */
  58557. targetFrameRate: number;
  58558. /**
  58559. * Gets or sets the current interval between two checks (every 2000ms by default)
  58560. */
  58561. /**
  58562. * Gets or sets the current interval between two checks (every 2000ms by default)
  58563. */
  58564. trackerDuration: number;
  58565. /**
  58566. * Gets the list of active optimizations
  58567. */
  58568. readonly optimizations: SceneOptimization[];
  58569. /**
  58570. * Creates a new SceneOptimizer
  58571. * @param scene defines the scene to work on
  58572. * @param options defines the options to use with the SceneOptimizer
  58573. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58574. * @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)
  58575. */
  58576. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58577. /**
  58578. * Stops the current optimizer
  58579. */
  58580. stop(): void;
  58581. /**
  58582. * Reset the optimizer to initial step (current priority level = 0)
  58583. */
  58584. reset(): void;
  58585. /**
  58586. * Start the optimizer. By default it will try to reach a specific framerate
  58587. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58588. */
  58589. start(): void;
  58590. private _checkCurrentState;
  58591. /**
  58592. * Release all resources
  58593. */
  58594. dispose(): void;
  58595. /**
  58596. * Helper function to create a SceneOptimizer with one single line of code
  58597. * @param scene defines the scene to work on
  58598. * @param options defines the options to use with the SceneOptimizer
  58599. * @param onSuccess defines a callback to call on success
  58600. * @param onFailure defines a callback to call on failure
  58601. * @returns the new SceneOptimizer object
  58602. */
  58603. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58604. }
  58605. }
  58606. declare module "babylonjs/Misc/sceneSerializer" {
  58607. import { Scene } from "babylonjs/scene";
  58608. /**
  58609. * Class used to serialize a scene into a string
  58610. */
  58611. export class SceneSerializer {
  58612. /**
  58613. * Clear cache used by a previous serialization
  58614. */
  58615. static ClearCache(): void;
  58616. /**
  58617. * Serialize a scene into a JSON compatible object
  58618. * @param scene defines the scene to serialize
  58619. * @returns a JSON compatible object
  58620. */
  58621. static Serialize(scene: Scene): any;
  58622. /**
  58623. * Serialize a mesh into a JSON compatible object
  58624. * @param toSerialize defines the mesh to serialize
  58625. * @param withParents defines if parents must be serialized as well
  58626. * @param withChildren defines if children must be serialized as well
  58627. * @returns a JSON compatible object
  58628. */
  58629. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58630. }
  58631. }
  58632. declare module "babylonjs/Misc/textureTools" {
  58633. import { Texture } from "babylonjs/Materials/Textures/texture";
  58634. /**
  58635. * Class used to host texture specific utilities
  58636. */
  58637. export class TextureTools {
  58638. /**
  58639. * Uses the GPU to create a copy texture rescaled at a given size
  58640. * @param texture Texture to copy from
  58641. * @param width defines the desired width
  58642. * @param height defines the desired height
  58643. * @param useBilinearMode defines if bilinear mode has to be used
  58644. * @return the generated texture
  58645. */
  58646. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58647. }
  58648. }
  58649. declare module "babylonjs/Misc/videoRecorder" {
  58650. import { Nullable } from "babylonjs/types";
  58651. import { Engine } from "babylonjs/Engines/engine";
  58652. /**
  58653. * This represents the different options avilable for the video capture.
  58654. */
  58655. export interface VideoRecorderOptions {
  58656. /** Defines the mime type of the video */
  58657. mimeType: string;
  58658. /** Defines the video the video should be recorded at */
  58659. fps: number;
  58660. /** Defines the chunk size for the recording data */
  58661. recordChunckSize: number;
  58662. /** The audio tracks to attach to the record */
  58663. audioTracks?: MediaStreamTrack[];
  58664. }
  58665. /**
  58666. * This can helps recording videos from BabylonJS.
  58667. * This is based on the available WebRTC functionalities of the browser.
  58668. *
  58669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58670. */
  58671. export class VideoRecorder {
  58672. private static readonly _defaultOptions;
  58673. /**
  58674. * Returns wehther or not the VideoRecorder is available in your browser.
  58675. * @param engine Defines the Babylon Engine to check the support for
  58676. * @returns true if supported otherwise false
  58677. */
  58678. static IsSupported(engine: Engine): boolean;
  58679. private readonly _options;
  58680. private _canvas;
  58681. private _mediaRecorder;
  58682. private _recordedChunks;
  58683. private _fileName;
  58684. private _resolve;
  58685. private _reject;
  58686. /**
  58687. * True wether a recording is already in progress.
  58688. */
  58689. readonly isRecording: boolean;
  58690. /**
  58691. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58692. * a video file.
  58693. * @param engine Defines the BabylonJS Engine you wish to record
  58694. * @param options Defines options that can be used to customized the capture
  58695. */
  58696. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58697. /**
  58698. * Stops the current recording before the default capture timeout passed in the startRecording
  58699. * functions.
  58700. */
  58701. stopRecording(): void;
  58702. /**
  58703. * Starts recording the canvas for a max duration specified in parameters.
  58704. * @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.
  58705. * @param maxDuration Defines the maximum recording time in seconds.
  58706. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58707. * @return a promise callback at the end of the recording with the video data in Blob.
  58708. */
  58709. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58710. /**
  58711. * Releases internal resources used during the recording.
  58712. */
  58713. dispose(): void;
  58714. private _handleDataAvailable;
  58715. private _handleError;
  58716. private _handleStop;
  58717. }
  58718. }
  58719. declare module "babylonjs/Misc/screenshotTools" {
  58720. import { Camera } from "babylonjs/Cameras/camera";
  58721. import { Engine } from "babylonjs/Engines/engine";
  58722. /**
  58723. * Class containing a set of static utilities functions for screenshots
  58724. */
  58725. export class ScreenshotTools {
  58726. /**
  58727. * Captures a screenshot of the current rendering
  58728. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58729. * @param engine defines the rendering engine
  58730. * @param camera defines the source camera
  58731. * @param size This parameter can be set to a single number or to an object with the
  58732. * following (optional) properties: precision, width, height. If a single number is passed,
  58733. * it will be used for both width and height. If an object is passed, the screenshot size
  58734. * will be derived from the parameters. The precision property is a multiplier allowing
  58735. * rendering at a higher or lower resolution
  58736. * @param successCallback defines the callback receives a single parameter which contains the
  58737. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58738. * src parameter of an <img> to display it
  58739. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58740. * Check your browser for supported MIME types
  58741. */
  58742. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58743. /**
  58744. * Generates an image screenshot from the specified camera.
  58745. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58746. * @param engine The engine to use for rendering
  58747. * @param camera The camera to use for rendering
  58748. * @param size This parameter can be set to a single number or to an object with the
  58749. * following (optional) properties: precision, width, height. If a single number is passed,
  58750. * it will be used for both width and height. If an object is passed, the screenshot size
  58751. * will be derived from the parameters. The precision property is a multiplier allowing
  58752. * rendering at a higher or lower resolution
  58753. * @param successCallback The callback receives a single parameter which contains the
  58754. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58755. * src parameter of an <img> to display it
  58756. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58757. * Check your browser for supported MIME types
  58758. * @param samples Texture samples (default: 1)
  58759. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58760. * @param fileName A name for for the downloaded file.
  58761. */
  58762. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58763. }
  58764. }
  58765. declare module "babylonjs/Misc/index" {
  58766. export * from "babylonjs/Misc/andOrNotEvaluator";
  58767. export * from "babylonjs/Misc/assetsManager";
  58768. export * from "babylonjs/Misc/dds";
  58769. export * from "babylonjs/Misc/decorators";
  58770. export * from "babylonjs/Misc/deferred";
  58771. export * from "babylonjs/Misc/environmentTextureTools";
  58772. export * from "babylonjs/Misc/meshExploder";
  58773. export * from "babylonjs/Misc/filesInput";
  58774. export * from "babylonjs/Misc/HighDynamicRange/index";
  58775. export * from "babylonjs/Misc/khronosTextureContainer";
  58776. export * from "babylonjs/Misc/observable";
  58777. export * from "babylonjs/Misc/performanceMonitor";
  58778. export * from "babylonjs/Misc/promise";
  58779. export * from "babylonjs/Misc/sceneOptimizer";
  58780. export * from "babylonjs/Misc/sceneSerializer";
  58781. export * from "babylonjs/Misc/smartArray";
  58782. export * from "babylonjs/Misc/stringDictionary";
  58783. export * from "babylonjs/Misc/tags";
  58784. export * from "babylonjs/Misc/textureTools";
  58785. export * from "babylonjs/Misc/tga";
  58786. export * from "babylonjs/Misc/tools";
  58787. export * from "babylonjs/Misc/videoRecorder";
  58788. export * from "babylonjs/Misc/virtualJoystick";
  58789. export * from "babylonjs/Misc/workerPool";
  58790. export * from "babylonjs/Misc/logger";
  58791. export * from "babylonjs/Misc/typeStore";
  58792. export * from "babylonjs/Misc/filesInputStore";
  58793. export * from "babylonjs/Misc/deepCopier";
  58794. export * from "babylonjs/Misc/pivotTools";
  58795. export * from "babylonjs/Misc/precisionDate";
  58796. export * from "babylonjs/Misc/screenshotTools";
  58797. export * from "babylonjs/Misc/typeStore";
  58798. export * from "babylonjs/Misc/webRequest";
  58799. export * from "babylonjs/Misc/iInspectable";
  58800. }
  58801. declare module "babylonjs/index" {
  58802. export * from "babylonjs/abstractScene";
  58803. export * from "babylonjs/Actions/index";
  58804. export * from "babylonjs/Animations/index";
  58805. export * from "babylonjs/assetContainer";
  58806. export * from "babylonjs/Audio/index";
  58807. export * from "babylonjs/Behaviors/index";
  58808. export * from "babylonjs/Bones/index";
  58809. export * from "babylonjs/Cameras/index";
  58810. export * from "babylonjs/Collisions/index";
  58811. export * from "babylonjs/Culling/index";
  58812. export * from "babylonjs/Debug/index";
  58813. export * from "babylonjs/Engines/index";
  58814. export * from "babylonjs/Events/index";
  58815. export * from "babylonjs/Gamepads/index";
  58816. export * from "babylonjs/Gizmos/index";
  58817. export * from "babylonjs/Helpers/index";
  58818. export * from "babylonjs/Instrumentation/index";
  58819. export * from "babylonjs/Layers/index";
  58820. export * from "babylonjs/LensFlares/index";
  58821. export * from "babylonjs/Lights/index";
  58822. export * from "babylonjs/Loading/index";
  58823. export * from "babylonjs/Materials/index";
  58824. export * from "babylonjs/Maths/index";
  58825. export * from "babylonjs/Meshes/index";
  58826. export * from "babylonjs/Morph/index";
  58827. export * from "babylonjs/node";
  58828. export * from "babylonjs/Offline/index";
  58829. export * from "babylonjs/Particles/index";
  58830. export * from "babylonjs/Physics/index";
  58831. export * from "babylonjs/PostProcesses/index";
  58832. export * from "babylonjs/Probes/index";
  58833. export * from "babylonjs/Rendering/index";
  58834. export * from "babylonjs/scene";
  58835. export * from "babylonjs/sceneComponent";
  58836. export * from "babylonjs/Sprites/index";
  58837. export * from "babylonjs/States/index";
  58838. export * from "babylonjs/Misc/index";
  58839. export * from "babylonjs/types";
  58840. }
  58841. declare module "babylonjs/Animations/pathCursor" {
  58842. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58843. /**
  58844. * A cursor which tracks a point on a path
  58845. */
  58846. export class PathCursor {
  58847. private path;
  58848. /**
  58849. * Stores path cursor callbacks for when an onchange event is triggered
  58850. */
  58851. private _onchange;
  58852. /**
  58853. * The value of the path cursor
  58854. */
  58855. value: number;
  58856. /**
  58857. * The animation array of the path cursor
  58858. */
  58859. animations: Animation[];
  58860. /**
  58861. * Initializes the path cursor
  58862. * @param path The path to track
  58863. */
  58864. constructor(path: Path2);
  58865. /**
  58866. * Gets the cursor point on the path
  58867. * @returns A point on the path cursor at the cursor location
  58868. */
  58869. getPoint(): Vector3;
  58870. /**
  58871. * Moves the cursor ahead by the step amount
  58872. * @param step The amount to move the cursor forward
  58873. * @returns This path cursor
  58874. */
  58875. moveAhead(step?: number): PathCursor;
  58876. /**
  58877. * Moves the cursor behind by the step amount
  58878. * @param step The amount to move the cursor back
  58879. * @returns This path cursor
  58880. */
  58881. moveBack(step?: number): PathCursor;
  58882. /**
  58883. * Moves the cursor by the step amount
  58884. * If the step amount is greater than one, an exception is thrown
  58885. * @param step The amount to move the cursor
  58886. * @returns This path cursor
  58887. */
  58888. move(step: number): PathCursor;
  58889. /**
  58890. * Ensures that the value is limited between zero and one
  58891. * @returns This path cursor
  58892. */
  58893. private ensureLimits;
  58894. /**
  58895. * Runs onchange callbacks on change (used by the animation engine)
  58896. * @returns This path cursor
  58897. */
  58898. private raiseOnChange;
  58899. /**
  58900. * Executes a function on change
  58901. * @param f A path cursor onchange callback
  58902. * @returns This path cursor
  58903. */
  58904. onchange(f: (cursor: PathCursor) => void): PathCursor;
  58905. }
  58906. }
  58907. declare module "babylonjs/Legacy/legacy" {
  58908. import * as Babylon from "babylonjs/index";
  58909. export * from "babylonjs/index";
  58910. }
  58911. declare module "babylonjs/Shaders/blur.fragment" {
  58912. /** @hidden */
  58913. export var blurPixelShader: {
  58914. name: string;
  58915. shader: string;
  58916. };
  58917. }
  58918. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  58919. /** @hidden */
  58920. export var bones300Declaration: {
  58921. name: string;
  58922. shader: string;
  58923. };
  58924. }
  58925. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  58926. /** @hidden */
  58927. export var instances300Declaration: {
  58928. name: string;
  58929. shader: string;
  58930. };
  58931. }
  58932. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  58933. /** @hidden */
  58934. export var pointCloudVertexDeclaration: {
  58935. name: string;
  58936. shader: string;
  58937. };
  58938. }
  58939. // Mixins
  58940. interface Window {
  58941. mozIndexedDB: IDBFactory;
  58942. webkitIndexedDB: IDBFactory;
  58943. msIndexedDB: IDBFactory;
  58944. webkitURL: typeof URL;
  58945. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  58946. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  58947. WebGLRenderingContext: WebGLRenderingContext;
  58948. MSGesture: MSGesture;
  58949. CANNON: any;
  58950. AudioContext: AudioContext;
  58951. webkitAudioContext: AudioContext;
  58952. PointerEvent: any;
  58953. Math: Math;
  58954. Uint8Array: Uint8ArrayConstructor;
  58955. Float32Array: Float32ArrayConstructor;
  58956. mozURL: typeof URL;
  58957. msURL: typeof URL;
  58958. VRFrameData: any; // WebVR, from specs 1.1
  58959. DracoDecoderModule: any;
  58960. setImmediate(handler: (...args: any[]) => void): number;
  58961. }
  58962. interface HTMLCanvasElement {
  58963. requestPointerLock(): void;
  58964. msRequestPointerLock?(): void;
  58965. mozRequestPointerLock?(): void;
  58966. webkitRequestPointerLock?(): void;
  58967. /** Track wether a record is in progress */
  58968. isRecording: boolean;
  58969. /** Capture Stream method defined by some browsers */
  58970. captureStream(fps?: number): MediaStream;
  58971. }
  58972. interface CanvasRenderingContext2D {
  58973. msImageSmoothingEnabled: boolean;
  58974. }
  58975. interface MouseEvent {
  58976. mozMovementX: number;
  58977. mozMovementY: number;
  58978. webkitMovementX: number;
  58979. webkitMovementY: number;
  58980. msMovementX: number;
  58981. msMovementY: number;
  58982. }
  58983. interface Navigator {
  58984. mozGetVRDevices: (any: any) => any;
  58985. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58986. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58987. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  58988. webkitGetGamepads(): Gamepad[];
  58989. msGetGamepads(): Gamepad[];
  58990. webkitGamepads(): Gamepad[];
  58991. }
  58992. interface HTMLVideoElement {
  58993. mozSrcObject: any;
  58994. }
  58995. interface Math {
  58996. fround(x: number): number;
  58997. imul(a: number, b: number): number;
  58998. }
  58999. interface WebGLProgram {
  59000. context?: WebGLRenderingContext;
  59001. vertexShader?: WebGLShader;
  59002. fragmentShader?: WebGLShader;
  59003. isParallelCompiled: boolean;
  59004. onCompiled?: () => void;
  59005. }
  59006. interface WebGLRenderingContext {
  59007. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59008. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59009. vertexAttribDivisor(index: number, divisor: number): void;
  59010. createVertexArray(): any;
  59011. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59012. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59013. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59014. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59015. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59016. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59017. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59018. // Queries
  59019. createQuery(): WebGLQuery;
  59020. deleteQuery(query: WebGLQuery): void;
  59021. beginQuery(target: number, query: WebGLQuery): void;
  59022. endQuery(target: number): void;
  59023. getQueryParameter(query: WebGLQuery, pname: number): any;
  59024. getQuery(target: number, pname: number): any;
  59025. MAX_SAMPLES: number;
  59026. RGBA8: number;
  59027. READ_FRAMEBUFFER: number;
  59028. DRAW_FRAMEBUFFER: number;
  59029. UNIFORM_BUFFER: number;
  59030. HALF_FLOAT_OES: number;
  59031. RGBA16F: number;
  59032. RGBA32F: number;
  59033. R32F: number;
  59034. RG32F: number;
  59035. RGB32F: number;
  59036. R16F: number;
  59037. RG16F: number;
  59038. RGB16F: number;
  59039. RED: number;
  59040. RG: number;
  59041. R8: number;
  59042. RG8: number;
  59043. UNSIGNED_INT_24_8: number;
  59044. DEPTH24_STENCIL8: number;
  59045. /* Multiple Render Targets */
  59046. drawBuffers(buffers: number[]): void;
  59047. readBuffer(src: number): void;
  59048. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59049. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59050. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59051. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59052. // Occlusion Query
  59053. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59054. ANY_SAMPLES_PASSED: number;
  59055. QUERY_RESULT_AVAILABLE: number;
  59056. QUERY_RESULT: number;
  59057. }
  59058. interface WebGLBuffer {
  59059. references: number;
  59060. capacity: number;
  59061. is32Bits: boolean;
  59062. }
  59063. interface WebGLProgram {
  59064. transformFeedback?: WebGLTransformFeedback | null;
  59065. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59066. }
  59067. interface EXT_disjoint_timer_query {
  59068. QUERY_COUNTER_BITS_EXT: number;
  59069. TIME_ELAPSED_EXT: number;
  59070. TIMESTAMP_EXT: number;
  59071. GPU_DISJOINT_EXT: number;
  59072. QUERY_RESULT_EXT: number;
  59073. QUERY_RESULT_AVAILABLE_EXT: number;
  59074. queryCounterEXT(query: WebGLQuery, target: number): void;
  59075. createQueryEXT(): WebGLQuery;
  59076. beginQueryEXT(target: number, query: WebGLQuery): void;
  59077. endQueryEXT(target: number): void;
  59078. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59079. deleteQueryEXT(query: WebGLQuery): void;
  59080. }
  59081. interface WebGLUniformLocation {
  59082. _currentState: any;
  59083. }
  59084. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59085. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59086. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59087. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59088. interface WebGLRenderingContext {
  59089. readonly RASTERIZER_DISCARD: number;
  59090. readonly DEPTH_COMPONENT24: number;
  59091. readonly TEXTURE_3D: number;
  59092. readonly TEXTURE_2D_ARRAY: number;
  59093. readonly TEXTURE_COMPARE_FUNC: number;
  59094. readonly TEXTURE_COMPARE_MODE: number;
  59095. readonly COMPARE_REF_TO_TEXTURE: number;
  59096. readonly TEXTURE_WRAP_R: number;
  59097. readonly HALF_FLOAT: number;
  59098. readonly RGB8: number;
  59099. readonly RED_INTEGER: number;
  59100. readonly RG_INTEGER: number;
  59101. readonly RGB_INTEGER: number;
  59102. readonly RGBA_INTEGER: number;
  59103. readonly R8_SNORM: number;
  59104. readonly RG8_SNORM: number;
  59105. readonly RGB8_SNORM: number;
  59106. readonly RGBA8_SNORM: number;
  59107. readonly R8I: number;
  59108. readonly RG8I: number;
  59109. readonly RGB8I: number;
  59110. readonly RGBA8I: number;
  59111. readonly R8UI: number;
  59112. readonly RG8UI: number;
  59113. readonly RGB8UI: number;
  59114. readonly RGBA8UI: number;
  59115. readonly R16I: number;
  59116. readonly RG16I: number;
  59117. readonly RGB16I: number;
  59118. readonly RGBA16I: number;
  59119. readonly R16UI: number;
  59120. readonly RG16UI: number;
  59121. readonly RGB16UI: number;
  59122. readonly RGBA16UI: number;
  59123. readonly R32I: number;
  59124. readonly RG32I: number;
  59125. readonly RGB32I: number;
  59126. readonly RGBA32I: number;
  59127. readonly R32UI: number;
  59128. readonly RG32UI: number;
  59129. readonly RGB32UI: number;
  59130. readonly RGBA32UI: number;
  59131. readonly RGB10_A2UI: number;
  59132. readonly R11F_G11F_B10F: number;
  59133. readonly RGB9_E5: number;
  59134. readonly RGB10_A2: number;
  59135. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59136. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59137. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59138. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59139. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59140. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59141. 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;
  59142. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59143. readonly TRANSFORM_FEEDBACK: number;
  59144. readonly INTERLEAVED_ATTRIBS: number;
  59145. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59146. createTransformFeedback(): WebGLTransformFeedback;
  59147. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59148. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59149. beginTransformFeedback(primitiveMode: number): void;
  59150. endTransformFeedback(): void;
  59151. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59152. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59153. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59154. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59155. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59156. }
  59157. interface ImageBitmap {
  59158. readonly width: number;
  59159. readonly height: number;
  59160. close(): void;
  59161. }
  59162. interface WebGLQuery extends WebGLObject {
  59163. }
  59164. declare var WebGLQuery: {
  59165. prototype: WebGLQuery;
  59166. new(): WebGLQuery;
  59167. };
  59168. interface WebGLSampler extends WebGLObject {
  59169. }
  59170. declare var WebGLSampler: {
  59171. prototype: WebGLSampler;
  59172. new(): WebGLSampler;
  59173. };
  59174. interface WebGLSync extends WebGLObject {
  59175. }
  59176. declare var WebGLSync: {
  59177. prototype: WebGLSync;
  59178. new(): WebGLSync;
  59179. };
  59180. interface WebGLTransformFeedback extends WebGLObject {
  59181. }
  59182. declare var WebGLTransformFeedback: {
  59183. prototype: WebGLTransformFeedback;
  59184. new(): WebGLTransformFeedback;
  59185. };
  59186. interface WebGLVertexArrayObject extends WebGLObject {
  59187. }
  59188. declare var WebGLVertexArrayObject: {
  59189. prototype: WebGLVertexArrayObject;
  59190. new(): WebGLVertexArrayObject;
  59191. };
  59192. // Type definitions for WebVR API
  59193. // Project: https://w3c.github.io/webvr/
  59194. // Definitions by: six a <https://github.com/lostfictions>
  59195. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59196. interface VRDisplay extends EventTarget {
  59197. /**
  59198. * Dictionary of capabilities describing the VRDisplay.
  59199. */
  59200. readonly capabilities: VRDisplayCapabilities;
  59201. /**
  59202. * z-depth defining the far plane of the eye view frustum
  59203. * enables mapping of values in the render target depth
  59204. * attachment to scene coordinates. Initially set to 10000.0.
  59205. */
  59206. depthFar: number;
  59207. /**
  59208. * z-depth defining the near plane of the eye view frustum
  59209. * enables mapping of values in the render target depth
  59210. * attachment to scene coordinates. Initially set to 0.01.
  59211. */
  59212. depthNear: number;
  59213. /**
  59214. * An identifier for this distinct VRDisplay. Used as an
  59215. * association point in the Gamepad API.
  59216. */
  59217. readonly displayId: number;
  59218. /**
  59219. * A display name, a user-readable name identifying it.
  59220. */
  59221. readonly displayName: string;
  59222. readonly isConnected: boolean;
  59223. readonly isPresenting: boolean;
  59224. /**
  59225. * If this VRDisplay supports room-scale experiences, the optional
  59226. * stage attribute contains details on the room-scale parameters.
  59227. */
  59228. readonly stageParameters: VRStageParameters | null;
  59229. /**
  59230. * Passing the value returned by `requestAnimationFrame` to
  59231. * `cancelAnimationFrame` will unregister the callback.
  59232. * @param handle Define the hanle of the request to cancel
  59233. */
  59234. cancelAnimationFrame(handle: number): void;
  59235. /**
  59236. * Stops presenting to the VRDisplay.
  59237. * @returns a promise to know when it stopped
  59238. */
  59239. exitPresent(): Promise<void>;
  59240. /**
  59241. * Return the current VREyeParameters for the given eye.
  59242. * @param whichEye Define the eye we want the parameter for
  59243. * @returns the eye parameters
  59244. */
  59245. getEyeParameters(whichEye: string): VREyeParameters;
  59246. /**
  59247. * Populates the passed VRFrameData with the information required to render
  59248. * the current frame.
  59249. * @param frameData Define the data structure to populate
  59250. * @returns true if ok otherwise false
  59251. */
  59252. getFrameData(frameData: VRFrameData): boolean;
  59253. /**
  59254. * Get the layers currently being presented.
  59255. * @returns the list of VR layers
  59256. */
  59257. getLayers(): VRLayer[];
  59258. /**
  59259. * Return a VRPose containing the future predicted pose of the VRDisplay
  59260. * when the current frame will be presented. The value returned will not
  59261. * change until JavaScript has returned control to the browser.
  59262. *
  59263. * The VRPose will contain the position, orientation, velocity,
  59264. * and acceleration of each of these properties.
  59265. * @returns the pose object
  59266. */
  59267. getPose(): VRPose;
  59268. /**
  59269. * Return the current instantaneous pose of the VRDisplay, with no
  59270. * prediction applied.
  59271. * @returns the current instantaneous pose
  59272. */
  59273. getImmediatePose(): VRPose;
  59274. /**
  59275. * The callback passed to `requestAnimationFrame` will be called
  59276. * any time a new frame should be rendered. When the VRDisplay is
  59277. * presenting the callback will be called at the native refresh
  59278. * rate of the HMD. When not presenting this function acts
  59279. * identically to how window.requestAnimationFrame acts. Content should
  59280. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59281. * asynchronously from other displays and at differing refresh rates.
  59282. * @param callback Define the eaction to run next frame
  59283. * @returns the request handle it
  59284. */
  59285. requestAnimationFrame(callback: FrameRequestCallback): number;
  59286. /**
  59287. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59288. * Repeat calls while already presenting will update the VRLayers being displayed.
  59289. * @param layers Define the list of layer to present
  59290. * @returns a promise to know when the request has been fulfilled
  59291. */
  59292. requestPresent(layers: VRLayer[]): Promise<void>;
  59293. /**
  59294. * Reset the pose for this display, treating its current position and
  59295. * orientation as the "origin/zero" values. VRPose.position,
  59296. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59297. * updated when calling resetPose(). This should be called in only
  59298. * sitting-space experiences.
  59299. */
  59300. resetPose(): void;
  59301. /**
  59302. * The VRLayer provided to the VRDisplay will be captured and presented
  59303. * in the HMD. Calling this function has the same effect on the source
  59304. * canvas as any other operation that uses its source image, and canvases
  59305. * created without preserveDrawingBuffer set to true will be cleared.
  59306. * @param pose Define the pose to submit
  59307. */
  59308. submitFrame(pose?: VRPose): void;
  59309. }
  59310. declare var VRDisplay: {
  59311. prototype: VRDisplay;
  59312. new(): VRDisplay;
  59313. };
  59314. interface VRLayer {
  59315. leftBounds?: number[] | Float32Array | null;
  59316. rightBounds?: number[] | Float32Array | null;
  59317. source?: HTMLCanvasElement | null;
  59318. }
  59319. interface VRDisplayCapabilities {
  59320. readonly canPresent: boolean;
  59321. readonly hasExternalDisplay: boolean;
  59322. readonly hasOrientation: boolean;
  59323. readonly hasPosition: boolean;
  59324. readonly maxLayers: number;
  59325. }
  59326. interface VREyeParameters {
  59327. /** @deprecated */
  59328. readonly fieldOfView: VRFieldOfView;
  59329. readonly offset: Float32Array;
  59330. readonly renderHeight: number;
  59331. readonly renderWidth: number;
  59332. }
  59333. interface VRFieldOfView {
  59334. readonly downDegrees: number;
  59335. readonly leftDegrees: number;
  59336. readonly rightDegrees: number;
  59337. readonly upDegrees: number;
  59338. }
  59339. interface VRFrameData {
  59340. readonly leftProjectionMatrix: Float32Array;
  59341. readonly leftViewMatrix: Float32Array;
  59342. readonly pose: VRPose;
  59343. readonly rightProjectionMatrix: Float32Array;
  59344. readonly rightViewMatrix: Float32Array;
  59345. readonly timestamp: number;
  59346. }
  59347. interface VRPose {
  59348. readonly angularAcceleration: Float32Array | null;
  59349. readonly angularVelocity: Float32Array | null;
  59350. readonly linearAcceleration: Float32Array | null;
  59351. readonly linearVelocity: Float32Array | null;
  59352. readonly orientation: Float32Array | null;
  59353. readonly position: Float32Array | null;
  59354. readonly timestamp: number;
  59355. }
  59356. interface VRStageParameters {
  59357. sittingToStandingTransform?: Float32Array;
  59358. sizeX?: number;
  59359. sizeY?: number;
  59360. }
  59361. interface Navigator {
  59362. getVRDisplays(): Promise<VRDisplay[]>;
  59363. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59364. }
  59365. interface Window {
  59366. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59367. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59368. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59369. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59370. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59371. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59372. }
  59373. interface Gamepad {
  59374. readonly displayId: number;
  59375. }
  59376. interface XRDevice {
  59377. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59378. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59379. }
  59380. interface XRSession {
  59381. getInputSources(): Array<any>;
  59382. baseLayer: XRWebGLLayer;
  59383. requestFrameOfReference(type: string): Promise<void>;
  59384. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59385. end(): Promise<void>;
  59386. requestAnimationFrame: Function;
  59387. addEventListener: Function;
  59388. }
  59389. interface XRSessionCreationOptions {
  59390. outputContext?: WebGLRenderingContext | null;
  59391. immersive?: boolean;
  59392. environmentIntegration?: boolean;
  59393. }
  59394. interface XRLayer {
  59395. getViewport: Function;
  59396. framebufferWidth: number;
  59397. framebufferHeight: number;
  59398. }
  59399. interface XRView {
  59400. projectionMatrix: Float32Array;
  59401. }
  59402. interface XRFrame {
  59403. getDevicePose: Function;
  59404. getInputPose: Function;
  59405. views: Array<XRView>;
  59406. baseLayer: XRLayer;
  59407. }
  59408. interface XRFrameOfReference {
  59409. }
  59410. interface XRWebGLLayer extends XRLayer {
  59411. framebuffer: WebGLFramebuffer;
  59412. }
  59413. declare var XRWebGLLayer: {
  59414. prototype: XRWebGLLayer;
  59415. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59416. };
  59417. declare module "babylonjs" {
  59418. export * from "babylonjs/Legacy/legacy";
  59419. }
  59420. declare module BABYLON {
  59421. /** Alias type for value that can be null */
  59422. export type Nullable<T> = T | null;
  59423. /**
  59424. * Alias type for number that are floats
  59425. * @ignorenaming
  59426. */
  59427. export type float = number;
  59428. /**
  59429. * Alias type for number that are doubles.
  59430. * @ignorenaming
  59431. */
  59432. export type double = number;
  59433. /**
  59434. * Alias type for number that are integer
  59435. * @ignorenaming
  59436. */
  59437. export type int = number;
  59438. /** Alias type for number array or Float32Array */
  59439. export type FloatArray = number[] | Float32Array;
  59440. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59441. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59442. /**
  59443. * Alias for types that can be used by a Buffer or VertexBuffer.
  59444. */
  59445. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59446. /**
  59447. * Alias type for primitive types
  59448. * @ignorenaming
  59449. */
  59450. type Primitive = undefined | null | boolean | string | number | Function;
  59451. /**
  59452. * Type modifier to make all the properties of an object Readonly
  59453. */
  59454. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59455. /**
  59456. * Type modifier to make all the properties of an object Readonly recursively
  59457. */
  59458. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59459. /** @hidden */
  59460. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59461. }
  59462. /** @hidden */
  59463. /** @hidden */
  59464. type DeepImmutableObject<T> = {
  59465. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59466. };
  59467. }
  59468. declare module BABYLON {
  59469. /**
  59470. * Class containing a set of static utilities functions for arrays.
  59471. */
  59472. export class ArrayTools {
  59473. /**
  59474. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59475. * @param size the number of element to construct and put in the array
  59476. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59477. * @returns a new array filled with new objects
  59478. */
  59479. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59480. }
  59481. }
  59482. declare module BABYLON {
  59483. /**
  59484. * Scalar computation library
  59485. */
  59486. export class Scalar {
  59487. /**
  59488. * Two pi constants convenient for computation.
  59489. */
  59490. static TwoPi: number;
  59491. /**
  59492. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59493. * @param a number
  59494. * @param b number
  59495. * @param epsilon (default = 1.401298E-45)
  59496. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59497. */
  59498. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59499. /**
  59500. * Returns a string : the upper case translation of the number i to hexadecimal.
  59501. * @param i number
  59502. * @returns the upper case translation of the number i to hexadecimal.
  59503. */
  59504. static ToHex(i: number): string;
  59505. /**
  59506. * Returns -1 if value is negative and +1 is value is positive.
  59507. * @param value the value
  59508. * @returns the value itself if it's equal to zero.
  59509. */
  59510. static Sign(value: number): number;
  59511. /**
  59512. * Returns the value itself if it's between min and max.
  59513. * Returns min if the value is lower than min.
  59514. * Returns max if the value is greater than max.
  59515. * @param value the value to clmap
  59516. * @param min the min value to clamp to (default: 0)
  59517. * @param max the max value to clamp to (default: 1)
  59518. * @returns the clamped value
  59519. */
  59520. static Clamp(value: number, min?: number, max?: number): number;
  59521. /**
  59522. * the log2 of value.
  59523. * @param value the value to compute log2 of
  59524. * @returns the log2 of value.
  59525. */
  59526. static Log2(value: number): number;
  59527. /**
  59528. * Loops the value, so that it is never larger than length and never smaller than 0.
  59529. *
  59530. * This is similar to the modulo operator but it works with floating point numbers.
  59531. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59532. * With t = 5 and length = 2.5, the result would be 0.0.
  59533. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59534. * @param value the value
  59535. * @param length the length
  59536. * @returns the looped value
  59537. */
  59538. static Repeat(value: number, length: number): number;
  59539. /**
  59540. * Normalize the value between 0.0 and 1.0 using min and max values
  59541. * @param value value to normalize
  59542. * @param min max to normalize between
  59543. * @param max min to normalize between
  59544. * @returns the normalized value
  59545. */
  59546. static Normalize(value: number, min: number, max: number): number;
  59547. /**
  59548. * Denormalize the value from 0.0 and 1.0 using min and max values
  59549. * @param normalized value to denormalize
  59550. * @param min max to denormalize between
  59551. * @param max min to denormalize between
  59552. * @returns the denormalized value
  59553. */
  59554. static Denormalize(normalized: number, min: number, max: number): number;
  59555. /**
  59556. * Calculates the shortest difference between two given angles given in degrees.
  59557. * @param current current angle in degrees
  59558. * @param target target angle in degrees
  59559. * @returns the delta
  59560. */
  59561. static DeltaAngle(current: number, target: number): number;
  59562. /**
  59563. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59564. * @param tx value
  59565. * @param length length
  59566. * @returns The returned value will move back and forth between 0 and length
  59567. */
  59568. static PingPong(tx: number, length: number): number;
  59569. /**
  59570. * Interpolates between min and max with smoothing at the limits.
  59571. *
  59572. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59573. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59574. * @param from from
  59575. * @param to to
  59576. * @param tx value
  59577. * @returns the smooth stepped value
  59578. */
  59579. static SmoothStep(from: number, to: number, tx: number): number;
  59580. /**
  59581. * Moves a value current towards target.
  59582. *
  59583. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59584. * Negative values of maxDelta pushes the value away from target.
  59585. * @param current current value
  59586. * @param target target value
  59587. * @param maxDelta max distance to move
  59588. * @returns resulting value
  59589. */
  59590. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59591. /**
  59592. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59593. *
  59594. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59595. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59596. * @param current current value
  59597. * @param target target value
  59598. * @param maxDelta max distance to move
  59599. * @returns resulting angle
  59600. */
  59601. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59602. /**
  59603. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59604. * @param start start value
  59605. * @param end target value
  59606. * @param amount amount to lerp between
  59607. * @returns the lerped value
  59608. */
  59609. static Lerp(start: number, end: number, amount: number): number;
  59610. /**
  59611. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59612. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59613. * @param start start value
  59614. * @param end target value
  59615. * @param amount amount to lerp between
  59616. * @returns the lerped value
  59617. */
  59618. static LerpAngle(start: number, end: number, amount: number): number;
  59619. /**
  59620. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59621. * @param a start value
  59622. * @param b target value
  59623. * @param value value between a and b
  59624. * @returns the inverseLerp value
  59625. */
  59626. static InverseLerp(a: number, b: number, value: number): number;
  59627. /**
  59628. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59629. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59630. * @param value1 spline value
  59631. * @param tangent1 spline value
  59632. * @param value2 spline value
  59633. * @param tangent2 spline value
  59634. * @param amount input value
  59635. * @returns hermite result
  59636. */
  59637. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59638. /**
  59639. * Returns a random float number between and min and max values
  59640. * @param min min value of random
  59641. * @param max max value of random
  59642. * @returns random value
  59643. */
  59644. static RandomRange(min: number, max: number): number;
  59645. /**
  59646. * This function returns percentage of a number in a given range.
  59647. *
  59648. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59649. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59650. * @param number to convert to percentage
  59651. * @param min min range
  59652. * @param max max range
  59653. * @returns the percentage
  59654. */
  59655. static RangeToPercent(number: number, min: number, max: number): number;
  59656. /**
  59657. * This function returns number that corresponds to the percentage in a given range.
  59658. *
  59659. * PercentToRange(0.34,0,100) will return 34.
  59660. * @param percent to convert to number
  59661. * @param min min range
  59662. * @param max max range
  59663. * @returns the number
  59664. */
  59665. static PercentToRange(percent: number, min: number, max: number): number;
  59666. /**
  59667. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59668. * @param angle The angle to normalize in radian.
  59669. * @return The converted angle.
  59670. */
  59671. static NormalizeRadians(angle: number): number;
  59672. }
  59673. }
  59674. declare module BABYLON {
  59675. /**
  59676. * Constant used to convert a value to gamma space
  59677. * @ignorenaming
  59678. */
  59679. export const ToGammaSpace: number;
  59680. /**
  59681. * Constant used to convert a value to linear space
  59682. * @ignorenaming
  59683. */
  59684. export const ToLinearSpace = 2.2;
  59685. /**
  59686. * Constant used to define the minimal number value in Babylon.js
  59687. * @ignorenaming
  59688. */
  59689. let Epsilon: number;
  59690. /**
  59691. * Class used to hold a RBG color
  59692. */
  59693. export class Color3 {
  59694. /**
  59695. * Defines the red component (between 0 and 1, default is 0)
  59696. */
  59697. r: number;
  59698. /**
  59699. * Defines the green component (between 0 and 1, default is 0)
  59700. */
  59701. g: number;
  59702. /**
  59703. * Defines the blue component (between 0 and 1, default is 0)
  59704. */
  59705. b: number;
  59706. /**
  59707. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59708. * @param r defines the red component (between 0 and 1, default is 0)
  59709. * @param g defines the green component (between 0 and 1, default is 0)
  59710. * @param b defines the blue component (between 0 and 1, default is 0)
  59711. */
  59712. constructor(
  59713. /**
  59714. * Defines the red component (between 0 and 1, default is 0)
  59715. */
  59716. r?: number,
  59717. /**
  59718. * Defines the green component (between 0 and 1, default is 0)
  59719. */
  59720. g?: number,
  59721. /**
  59722. * Defines the blue component (between 0 and 1, default is 0)
  59723. */
  59724. b?: number);
  59725. /**
  59726. * Creates a string with the Color3 current values
  59727. * @returns the string representation of the Color3 object
  59728. */
  59729. toString(): string;
  59730. /**
  59731. * Returns the string "Color3"
  59732. * @returns "Color3"
  59733. */
  59734. getClassName(): string;
  59735. /**
  59736. * Compute the Color3 hash code
  59737. * @returns an unique number that can be used to hash Color3 objects
  59738. */
  59739. getHashCode(): number;
  59740. /**
  59741. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59742. * @param array defines the array where to store the r,g,b components
  59743. * @param index defines an optional index in the target array to define where to start storing values
  59744. * @returns the current Color3 object
  59745. */
  59746. toArray(array: FloatArray, index?: number): Color3;
  59747. /**
  59748. * Returns a new Color4 object from the current Color3 and the given alpha
  59749. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59750. * @returns a new Color4 object
  59751. */
  59752. toColor4(alpha?: number): Color4;
  59753. /**
  59754. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59755. * @returns the new array
  59756. */
  59757. asArray(): number[];
  59758. /**
  59759. * Returns the luminance value
  59760. * @returns a float value
  59761. */
  59762. toLuminance(): number;
  59763. /**
  59764. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59765. * @param otherColor defines the second operand
  59766. * @returns the new Color3 object
  59767. */
  59768. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59769. /**
  59770. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59771. * @param otherColor defines the second operand
  59772. * @param result defines the Color3 object where to store the result
  59773. * @returns the current Color3
  59774. */
  59775. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59776. /**
  59777. * Determines equality between Color3 objects
  59778. * @param otherColor defines the second operand
  59779. * @returns true if the rgb values are equal to the given ones
  59780. */
  59781. equals(otherColor: DeepImmutable<Color3>): boolean;
  59782. /**
  59783. * Determines equality between the current Color3 object and a set of r,b,g values
  59784. * @param r defines the red component to check
  59785. * @param g defines the green component to check
  59786. * @param b defines the blue component to check
  59787. * @returns true if the rgb values are equal to the given ones
  59788. */
  59789. equalsFloats(r: number, g: number, b: number): boolean;
  59790. /**
  59791. * Multiplies in place each rgb value by scale
  59792. * @param scale defines the scaling factor
  59793. * @returns the updated Color3
  59794. */
  59795. scale(scale: number): Color3;
  59796. /**
  59797. * Multiplies the rgb values by scale and stores the result into "result"
  59798. * @param scale defines the scaling factor
  59799. * @param result defines the Color3 object where to store the result
  59800. * @returns the unmodified current Color3
  59801. */
  59802. scaleToRef(scale: number, result: Color3): Color3;
  59803. /**
  59804. * Scale the current Color3 values by a factor and add the result to a given Color3
  59805. * @param scale defines the scale factor
  59806. * @param result defines color to store the result into
  59807. * @returns the unmodified current Color3
  59808. */
  59809. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59810. /**
  59811. * Clamps the rgb values by the min and max values and stores the result into "result"
  59812. * @param min defines minimum clamping value (default is 0)
  59813. * @param max defines maximum clamping value (default is 1)
  59814. * @param result defines color to store the result into
  59815. * @returns the original Color3
  59816. */
  59817. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59818. /**
  59819. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59820. * @param otherColor defines the second operand
  59821. * @returns the new Color3
  59822. */
  59823. add(otherColor: DeepImmutable<Color3>): Color3;
  59824. /**
  59825. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59826. * @param otherColor defines the second operand
  59827. * @param result defines Color3 object to store the result into
  59828. * @returns the unmodified current Color3
  59829. */
  59830. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59831. /**
  59832. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59833. * @param otherColor defines the second operand
  59834. * @returns the new Color3
  59835. */
  59836. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59837. /**
  59838. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59839. * @param otherColor defines the second operand
  59840. * @param result defines Color3 object to store the result into
  59841. * @returns the unmodified current Color3
  59842. */
  59843. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59844. /**
  59845. * Copy the current object
  59846. * @returns a new Color3 copied the current one
  59847. */
  59848. clone(): Color3;
  59849. /**
  59850. * Copies the rgb values from the source in the current Color3
  59851. * @param source defines the source Color3 object
  59852. * @returns the updated Color3 object
  59853. */
  59854. copyFrom(source: DeepImmutable<Color3>): Color3;
  59855. /**
  59856. * Updates the Color3 rgb values from the given floats
  59857. * @param r defines the red component to read from
  59858. * @param g defines the green component to read from
  59859. * @param b defines the blue component to read from
  59860. * @returns the current Color3 object
  59861. */
  59862. copyFromFloats(r: number, g: number, b: number): Color3;
  59863. /**
  59864. * Updates the Color3 rgb values from the given floats
  59865. * @param r defines the red component to read from
  59866. * @param g defines the green component to read from
  59867. * @param b defines the blue component to read from
  59868. * @returns the current Color3 object
  59869. */
  59870. set(r: number, g: number, b: number): Color3;
  59871. /**
  59872. * Compute the Color3 hexadecimal code as a string
  59873. * @returns a string containing the hexadecimal representation of the Color3 object
  59874. */
  59875. toHexString(): string;
  59876. /**
  59877. * Computes a new Color3 converted from the current one to linear space
  59878. * @returns a new Color3 object
  59879. */
  59880. toLinearSpace(): Color3;
  59881. /**
  59882. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  59883. * @param convertedColor defines the Color3 object where to store the linear space version
  59884. * @returns the unmodified Color3
  59885. */
  59886. toLinearSpaceToRef(convertedColor: Color3): Color3;
  59887. /**
  59888. * Computes a new Color3 converted from the current one to gamma space
  59889. * @returns a new Color3 object
  59890. */
  59891. toGammaSpace(): Color3;
  59892. /**
  59893. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  59894. * @param convertedColor defines the Color3 object where to store the gamma space version
  59895. * @returns the unmodified Color3
  59896. */
  59897. toGammaSpaceToRef(convertedColor: Color3): Color3;
  59898. private static _BlackReadOnly;
  59899. /**
  59900. * Creates a new Color3 from the string containing valid hexadecimal values
  59901. * @param hex defines a string containing valid hexadecimal values
  59902. * @returns a new Color3 object
  59903. */
  59904. static FromHexString(hex: string): Color3;
  59905. /**
  59906. * Creates a new Color3 from the starting index of the given array
  59907. * @param array defines the source array
  59908. * @param offset defines an offset in the source array
  59909. * @returns a new Color3 object
  59910. */
  59911. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  59912. /**
  59913. * Creates a new Color3 from integer values (< 256)
  59914. * @param r defines the red component to read from (value between 0 and 255)
  59915. * @param g defines the green component to read from (value between 0 and 255)
  59916. * @param b defines the blue component to read from (value between 0 and 255)
  59917. * @returns a new Color3 object
  59918. */
  59919. static FromInts(r: number, g: number, b: number): Color3;
  59920. /**
  59921. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59922. * @param start defines the start Color3 value
  59923. * @param end defines the end Color3 value
  59924. * @param amount defines the gradient value between start and end
  59925. * @returns a new Color3 object
  59926. */
  59927. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  59928. /**
  59929. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  59930. * @param left defines the start value
  59931. * @param right defines the end value
  59932. * @param amount defines the gradient factor
  59933. * @param result defines the Color3 object where to store the result
  59934. */
  59935. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  59936. /**
  59937. * Returns a Color3 value containing a red color
  59938. * @returns a new Color3 object
  59939. */
  59940. static Red(): Color3;
  59941. /**
  59942. * Returns a Color3 value containing a green color
  59943. * @returns a new Color3 object
  59944. */
  59945. static Green(): Color3;
  59946. /**
  59947. * Returns a Color3 value containing a blue color
  59948. * @returns a new Color3 object
  59949. */
  59950. static Blue(): Color3;
  59951. /**
  59952. * Returns a Color3 value containing a black color
  59953. * @returns a new Color3 object
  59954. */
  59955. static Black(): Color3;
  59956. /**
  59957. * Gets a Color3 value containing a black color that must not be updated
  59958. */
  59959. static readonly BlackReadOnly: DeepImmutable<Color3>;
  59960. /**
  59961. * Returns a Color3 value containing a white color
  59962. * @returns a new Color3 object
  59963. */
  59964. static White(): Color3;
  59965. /**
  59966. * Returns a Color3 value containing a purple color
  59967. * @returns a new Color3 object
  59968. */
  59969. static Purple(): Color3;
  59970. /**
  59971. * Returns a Color3 value containing a magenta color
  59972. * @returns a new Color3 object
  59973. */
  59974. static Magenta(): Color3;
  59975. /**
  59976. * Returns a Color3 value containing a yellow color
  59977. * @returns a new Color3 object
  59978. */
  59979. static Yellow(): Color3;
  59980. /**
  59981. * Returns a Color3 value containing a gray color
  59982. * @returns a new Color3 object
  59983. */
  59984. static Gray(): Color3;
  59985. /**
  59986. * Returns a Color3 value containing a teal color
  59987. * @returns a new Color3 object
  59988. */
  59989. static Teal(): Color3;
  59990. /**
  59991. * Returns a Color3 value containing a random color
  59992. * @returns a new Color3 object
  59993. */
  59994. static Random(): Color3;
  59995. }
  59996. /**
  59997. * Class used to hold a RBGA color
  59998. */
  59999. export class Color4 {
  60000. /**
  60001. * Defines the red component (between 0 and 1, default is 0)
  60002. */
  60003. r: number;
  60004. /**
  60005. * Defines the green component (between 0 and 1, default is 0)
  60006. */
  60007. g: number;
  60008. /**
  60009. * Defines the blue component (between 0 and 1, default is 0)
  60010. */
  60011. b: number;
  60012. /**
  60013. * Defines the alpha component (between 0 and 1, default is 1)
  60014. */
  60015. a: number;
  60016. /**
  60017. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60018. * @param r defines the red component (between 0 and 1, default is 0)
  60019. * @param g defines the green component (between 0 and 1, default is 0)
  60020. * @param b defines the blue component (between 0 and 1, default is 0)
  60021. * @param a defines the alpha component (between 0 and 1, default is 1)
  60022. */
  60023. constructor(
  60024. /**
  60025. * Defines the red component (between 0 and 1, default is 0)
  60026. */
  60027. r?: number,
  60028. /**
  60029. * Defines the green component (between 0 and 1, default is 0)
  60030. */
  60031. g?: number,
  60032. /**
  60033. * Defines the blue component (between 0 and 1, default is 0)
  60034. */
  60035. b?: number,
  60036. /**
  60037. * Defines the alpha component (between 0 and 1, default is 1)
  60038. */
  60039. a?: number);
  60040. /**
  60041. * Adds in place the given Color4 values to the current Color4 object
  60042. * @param right defines the second operand
  60043. * @returns the current updated Color4 object
  60044. */
  60045. addInPlace(right: DeepImmutable<Color4>): Color4;
  60046. /**
  60047. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60048. * @returns the new array
  60049. */
  60050. asArray(): number[];
  60051. /**
  60052. * Stores from the starting index in the given array the Color4 successive values
  60053. * @param array defines the array where to store the r,g,b components
  60054. * @param index defines an optional index in the target array to define where to start storing values
  60055. * @returns the current Color4 object
  60056. */
  60057. toArray(array: number[], index?: number): Color4;
  60058. /**
  60059. * Determines equality between Color4 objects
  60060. * @param otherColor defines the second operand
  60061. * @returns true if the rgba values are equal to the given ones
  60062. */
  60063. equals(otherColor: DeepImmutable<Color4>): boolean;
  60064. /**
  60065. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60066. * @param right defines the second operand
  60067. * @returns a new Color4 object
  60068. */
  60069. add(right: DeepImmutable<Color4>): Color4;
  60070. /**
  60071. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60072. * @param right defines the second operand
  60073. * @returns a new Color4 object
  60074. */
  60075. subtract(right: DeepImmutable<Color4>): Color4;
  60076. /**
  60077. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60078. * @param right defines the second operand
  60079. * @param result defines the Color4 object where to store the result
  60080. * @returns the current Color4 object
  60081. */
  60082. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60083. /**
  60084. * Creates a new Color4 with the current Color4 values multiplied by scale
  60085. * @param scale defines the scaling factor to apply
  60086. * @returns a new Color4 object
  60087. */
  60088. scale(scale: number): Color4;
  60089. /**
  60090. * Multiplies the current Color4 values by scale and stores the result in "result"
  60091. * @param scale defines the scaling factor to apply
  60092. * @param result defines the Color4 object where to store the result
  60093. * @returns the current unmodified Color4
  60094. */
  60095. scaleToRef(scale: number, result: Color4): Color4;
  60096. /**
  60097. * Scale the current Color4 values by a factor and add the result to a given Color4
  60098. * @param scale defines the scale factor
  60099. * @param result defines the Color4 object where to store the result
  60100. * @returns the unmodified current Color4
  60101. */
  60102. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60103. /**
  60104. * Clamps the rgb values by the min and max values and stores the result into "result"
  60105. * @param min defines minimum clamping value (default is 0)
  60106. * @param max defines maximum clamping value (default is 1)
  60107. * @param result defines color to store the result into.
  60108. * @returns the cuurent Color4
  60109. */
  60110. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60111. /**
  60112. * Multipy an Color4 value by another and return a new Color4 object
  60113. * @param color defines the Color4 value to multiply by
  60114. * @returns a new Color4 object
  60115. */
  60116. multiply(color: Color4): Color4;
  60117. /**
  60118. * Multipy a Color4 value by another and push the result in a reference value
  60119. * @param color defines the Color4 value to multiply by
  60120. * @param result defines the Color4 to fill the result in
  60121. * @returns the result Color4
  60122. */
  60123. multiplyToRef(color: Color4, result: Color4): Color4;
  60124. /**
  60125. * Creates a string with the Color4 current values
  60126. * @returns the string representation of the Color4 object
  60127. */
  60128. toString(): string;
  60129. /**
  60130. * Returns the string "Color4"
  60131. * @returns "Color4"
  60132. */
  60133. getClassName(): string;
  60134. /**
  60135. * Compute the Color4 hash code
  60136. * @returns an unique number that can be used to hash Color4 objects
  60137. */
  60138. getHashCode(): number;
  60139. /**
  60140. * Creates a new Color4 copied from the current one
  60141. * @returns a new Color4 object
  60142. */
  60143. clone(): Color4;
  60144. /**
  60145. * Copies the given Color4 values into the current one
  60146. * @param source defines the source Color4 object
  60147. * @returns the current updated Color4 object
  60148. */
  60149. copyFrom(source: Color4): Color4;
  60150. /**
  60151. * Copies the given float values into the current one
  60152. * @param r defines the red component to read from
  60153. * @param g defines the green component to read from
  60154. * @param b defines the blue component to read from
  60155. * @param a defines the alpha component to read from
  60156. * @returns the current updated Color4 object
  60157. */
  60158. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60159. /**
  60160. * Copies the given float values into the current one
  60161. * @param r defines the red component to read from
  60162. * @param g defines the green component to read from
  60163. * @param b defines the blue component to read from
  60164. * @param a defines the alpha component to read from
  60165. * @returns the current updated Color4 object
  60166. */
  60167. set(r: number, g: number, b: number, a: number): Color4;
  60168. /**
  60169. * Compute the Color4 hexadecimal code as a string
  60170. * @returns a string containing the hexadecimal representation of the Color4 object
  60171. */
  60172. toHexString(): string;
  60173. /**
  60174. * Computes a new Color4 converted from the current one to linear space
  60175. * @returns a new Color4 object
  60176. */
  60177. toLinearSpace(): Color4;
  60178. /**
  60179. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60180. * @param convertedColor defines the Color4 object where to store the linear space version
  60181. * @returns the unmodified Color4
  60182. */
  60183. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60184. /**
  60185. * Computes a new Color4 converted from the current one to gamma space
  60186. * @returns a new Color4 object
  60187. */
  60188. toGammaSpace(): Color4;
  60189. /**
  60190. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60191. * @param convertedColor defines the Color4 object where to store the gamma space version
  60192. * @returns the unmodified Color4
  60193. */
  60194. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60195. /**
  60196. * Creates a new Color4 from the string containing valid hexadecimal values
  60197. * @param hex defines a string containing valid hexadecimal values
  60198. * @returns a new Color4 object
  60199. */
  60200. static FromHexString(hex: string): Color4;
  60201. /**
  60202. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60203. * @param left defines the start value
  60204. * @param right defines the end value
  60205. * @param amount defines the gradient factor
  60206. * @returns a new Color4 object
  60207. */
  60208. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60209. /**
  60210. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60211. * @param left defines the start value
  60212. * @param right defines the end value
  60213. * @param amount defines the gradient factor
  60214. * @param result defines the Color4 object where to store data
  60215. */
  60216. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60217. /**
  60218. * Creates a new Color4 from a Color3 and an alpha value
  60219. * @param color3 defines the source Color3 to read from
  60220. * @param alpha defines the alpha component (1.0 by default)
  60221. * @returns a new Color4 object
  60222. */
  60223. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60224. /**
  60225. * Creates a new Color4 from the starting index element of the given array
  60226. * @param array defines the source array to read from
  60227. * @param offset defines the offset in the source array
  60228. * @returns a new Color4 object
  60229. */
  60230. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60231. /**
  60232. * Creates a new Color3 from integer values (< 256)
  60233. * @param r defines the red component to read from (value between 0 and 255)
  60234. * @param g defines the green component to read from (value between 0 and 255)
  60235. * @param b defines the blue component to read from (value between 0 and 255)
  60236. * @param a defines the alpha component to read from (value between 0 and 255)
  60237. * @returns a new Color3 object
  60238. */
  60239. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60240. /**
  60241. * Check the content of a given array and convert it to an array containing RGBA data
  60242. * If the original array was already containing count * 4 values then it is returned directly
  60243. * @param colors defines the array to check
  60244. * @param count defines the number of RGBA data to expect
  60245. * @returns an array containing count * 4 values (RGBA)
  60246. */
  60247. static CheckColors4(colors: number[], count: number): number[];
  60248. }
  60249. /**
  60250. * Class representing a vector containing 2 coordinates
  60251. */
  60252. export class Vector2 {
  60253. /** defines the first coordinate */
  60254. x: number;
  60255. /** defines the second coordinate */
  60256. y: number;
  60257. /**
  60258. * Creates a new Vector2 from the given x and y coordinates
  60259. * @param x defines the first coordinate
  60260. * @param y defines the second coordinate
  60261. */
  60262. constructor(
  60263. /** defines the first coordinate */
  60264. x?: number,
  60265. /** defines the second coordinate */
  60266. y?: number);
  60267. /**
  60268. * Gets a string with the Vector2 coordinates
  60269. * @returns a string with the Vector2 coordinates
  60270. */
  60271. toString(): string;
  60272. /**
  60273. * Gets class name
  60274. * @returns the string "Vector2"
  60275. */
  60276. getClassName(): string;
  60277. /**
  60278. * Gets current vector hash code
  60279. * @returns the Vector2 hash code as a number
  60280. */
  60281. getHashCode(): number;
  60282. /**
  60283. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60284. * @param array defines the source array
  60285. * @param index defines the offset in source array
  60286. * @returns the current Vector2
  60287. */
  60288. toArray(array: FloatArray, index?: number): Vector2;
  60289. /**
  60290. * Copy the current vector to an array
  60291. * @returns a new array with 2 elements: the Vector2 coordinates.
  60292. */
  60293. asArray(): number[];
  60294. /**
  60295. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60296. * @param source defines the source Vector2
  60297. * @returns the current updated Vector2
  60298. */
  60299. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60300. /**
  60301. * Sets the Vector2 coordinates with the given floats
  60302. * @param x defines the first coordinate
  60303. * @param y defines the second coordinate
  60304. * @returns the current updated Vector2
  60305. */
  60306. copyFromFloats(x: number, y: number): Vector2;
  60307. /**
  60308. * Sets the Vector2 coordinates with the given floats
  60309. * @param x defines the first coordinate
  60310. * @param y defines the second coordinate
  60311. * @returns the current updated Vector2
  60312. */
  60313. set(x: number, y: number): Vector2;
  60314. /**
  60315. * Add another vector with the current one
  60316. * @param otherVector defines the other vector
  60317. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60318. */
  60319. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60320. /**
  60321. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60322. * @param otherVector defines the other vector
  60323. * @param result defines the target vector
  60324. * @returns the unmodified current Vector2
  60325. */
  60326. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60327. /**
  60328. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60329. * @param otherVector defines the other vector
  60330. * @returns the current updated Vector2
  60331. */
  60332. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60333. /**
  60334. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60335. * @param otherVector defines the other vector
  60336. * @returns a new Vector2
  60337. */
  60338. addVector3(otherVector: Vector3): Vector2;
  60339. /**
  60340. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60341. * @param otherVector defines the other vector
  60342. * @returns a new Vector2
  60343. */
  60344. subtract(otherVector: Vector2): Vector2;
  60345. /**
  60346. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60347. * @param otherVector defines the other vector
  60348. * @param result defines the target vector
  60349. * @returns the unmodified current Vector2
  60350. */
  60351. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60352. /**
  60353. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60354. * @param otherVector defines the other vector
  60355. * @returns the current updated Vector2
  60356. */
  60357. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60358. /**
  60359. * Multiplies in place the current Vector2 coordinates by the given ones
  60360. * @param otherVector defines the other vector
  60361. * @returns the current updated Vector2
  60362. */
  60363. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60364. /**
  60365. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60366. * @param otherVector defines the other vector
  60367. * @returns a new Vector2
  60368. */
  60369. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60370. /**
  60371. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60372. * @param otherVector defines the other vector
  60373. * @param result defines the target vector
  60374. * @returns the unmodified current Vector2
  60375. */
  60376. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60377. /**
  60378. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60379. * @param x defines the first coordinate
  60380. * @param y defines the second coordinate
  60381. * @returns a new Vector2
  60382. */
  60383. multiplyByFloats(x: number, y: number): Vector2;
  60384. /**
  60385. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60386. * @param otherVector defines the other vector
  60387. * @returns a new Vector2
  60388. */
  60389. divide(otherVector: Vector2): Vector2;
  60390. /**
  60391. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60392. * @param otherVector defines the other vector
  60393. * @param result defines the target vector
  60394. * @returns the unmodified current Vector2
  60395. */
  60396. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60397. /**
  60398. * Divides the current Vector2 coordinates by the given ones
  60399. * @param otherVector defines the other vector
  60400. * @returns the current updated Vector2
  60401. */
  60402. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60403. /**
  60404. * Gets a new Vector2 with current Vector2 negated coordinates
  60405. * @returns a new Vector2
  60406. */
  60407. negate(): Vector2;
  60408. /**
  60409. * Multiply the Vector2 coordinates by scale
  60410. * @param scale defines the scaling factor
  60411. * @returns the current updated Vector2
  60412. */
  60413. scaleInPlace(scale: number): Vector2;
  60414. /**
  60415. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60416. * @param scale defines the scaling factor
  60417. * @returns a new Vector2
  60418. */
  60419. scale(scale: number): Vector2;
  60420. /**
  60421. * Scale the current Vector2 values by a factor to a given Vector2
  60422. * @param scale defines the scale factor
  60423. * @param result defines the Vector2 object where to store the result
  60424. * @returns the unmodified current Vector2
  60425. */
  60426. scaleToRef(scale: number, result: Vector2): Vector2;
  60427. /**
  60428. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60429. * @param scale defines the scale factor
  60430. * @param result defines the Vector2 object where to store the result
  60431. * @returns the unmodified current Vector2
  60432. */
  60433. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60434. /**
  60435. * Gets a boolean if two vectors are equals
  60436. * @param otherVector defines the other vector
  60437. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60438. */
  60439. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60440. /**
  60441. * Gets a boolean if two vectors are equals (using an epsilon value)
  60442. * @param otherVector defines the other vector
  60443. * @param epsilon defines the minimal distance to consider equality
  60444. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60445. */
  60446. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60447. /**
  60448. * Gets a new Vector2 from current Vector2 floored values
  60449. * @returns a new Vector2
  60450. */
  60451. floor(): Vector2;
  60452. /**
  60453. * Gets a new Vector2 from current Vector2 floored values
  60454. * @returns a new Vector2
  60455. */
  60456. fract(): Vector2;
  60457. /**
  60458. * Gets the length of the vector
  60459. * @returns the vector length (float)
  60460. */
  60461. length(): number;
  60462. /**
  60463. * Gets the vector squared length
  60464. * @returns the vector squared length (float)
  60465. */
  60466. lengthSquared(): number;
  60467. /**
  60468. * Normalize the vector
  60469. * @returns the current updated Vector2
  60470. */
  60471. normalize(): Vector2;
  60472. /**
  60473. * Gets a new Vector2 copied from the Vector2
  60474. * @returns a new Vector2
  60475. */
  60476. clone(): Vector2;
  60477. /**
  60478. * Gets a new Vector2(0, 0)
  60479. * @returns a new Vector2
  60480. */
  60481. static Zero(): Vector2;
  60482. /**
  60483. * Gets a new Vector2(1, 1)
  60484. * @returns a new Vector2
  60485. */
  60486. static One(): Vector2;
  60487. /**
  60488. * Gets a new Vector2 set from the given index element of the given array
  60489. * @param array defines the data source
  60490. * @param offset defines the offset in the data source
  60491. * @returns a new Vector2
  60492. */
  60493. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60494. /**
  60495. * Sets "result" from the given index element of the given array
  60496. * @param array defines the data source
  60497. * @param offset defines the offset in the data source
  60498. * @param result defines the target vector
  60499. */
  60500. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60501. /**
  60502. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60503. * @param value1 defines 1st point of control
  60504. * @param value2 defines 2nd point of control
  60505. * @param value3 defines 3rd point of control
  60506. * @param value4 defines 4th point of control
  60507. * @param amount defines the interpolation factor
  60508. * @returns a new Vector2
  60509. */
  60510. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60511. /**
  60512. * 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".
  60513. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60514. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60515. * @param value defines the value to clamp
  60516. * @param min defines the lower limit
  60517. * @param max defines the upper limit
  60518. * @returns a new Vector2
  60519. */
  60520. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60521. /**
  60522. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60523. * @param value1 defines the 1st control point
  60524. * @param tangent1 defines the outgoing tangent
  60525. * @param value2 defines the 2nd control point
  60526. * @param tangent2 defines the incoming tangent
  60527. * @param amount defines the interpolation factor
  60528. * @returns a new Vector2
  60529. */
  60530. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60531. /**
  60532. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60533. * @param start defines the start vector
  60534. * @param end defines the end vector
  60535. * @param amount defines the interpolation factor
  60536. * @returns a new Vector2
  60537. */
  60538. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60539. /**
  60540. * Gets the dot product of the vector "left" and the vector "right"
  60541. * @param left defines first vector
  60542. * @param right defines second vector
  60543. * @returns the dot product (float)
  60544. */
  60545. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60546. /**
  60547. * Returns a new Vector2 equal to the normalized given vector
  60548. * @param vector defines the vector to normalize
  60549. * @returns a new Vector2
  60550. */
  60551. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60552. /**
  60553. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60554. * @param left defines 1st vector
  60555. * @param right defines 2nd vector
  60556. * @returns a new Vector2
  60557. */
  60558. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60559. /**
  60560. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60561. * @param left defines 1st vector
  60562. * @param right defines 2nd vector
  60563. * @returns a new Vector2
  60564. */
  60565. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60566. /**
  60567. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60568. * @param vector defines the vector to transform
  60569. * @param transformation defines the matrix to apply
  60570. * @returns a new Vector2
  60571. */
  60572. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60573. /**
  60574. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60575. * @param vector defines the vector to transform
  60576. * @param transformation defines the matrix to apply
  60577. * @param result defines the target vector
  60578. */
  60579. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60580. /**
  60581. * Determines if a given vector is included in a triangle
  60582. * @param p defines the vector to test
  60583. * @param p0 defines 1st triangle point
  60584. * @param p1 defines 2nd triangle point
  60585. * @param p2 defines 3rd triangle point
  60586. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60587. */
  60588. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60589. /**
  60590. * Gets the distance between the vectors "value1" and "value2"
  60591. * @param value1 defines first vector
  60592. * @param value2 defines second vector
  60593. * @returns the distance between vectors
  60594. */
  60595. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60596. /**
  60597. * Returns the squared distance between the vectors "value1" and "value2"
  60598. * @param value1 defines first vector
  60599. * @param value2 defines second vector
  60600. * @returns the squared distance between vectors
  60601. */
  60602. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60603. /**
  60604. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60605. * @param value1 defines first vector
  60606. * @param value2 defines second vector
  60607. * @returns a new Vector2
  60608. */
  60609. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60610. /**
  60611. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60612. * @param p defines the middle point
  60613. * @param segA defines one point of the segment
  60614. * @param segB defines the other point of the segment
  60615. * @returns the shortest distance
  60616. */
  60617. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60618. }
  60619. /**
  60620. * Classed used to store (x,y,z) vector representation
  60621. * A Vector3 is the main object used in 3D geometry
  60622. * It can represent etiher the coordinates of a point the space, either a direction
  60623. * Reminder: js uses a left handed forward facing system
  60624. */
  60625. export class Vector3 {
  60626. /**
  60627. * Defines the first coordinates (on X axis)
  60628. */
  60629. x: number;
  60630. /**
  60631. * Defines the second coordinates (on Y axis)
  60632. */
  60633. y: number;
  60634. /**
  60635. * Defines the third coordinates (on Z axis)
  60636. */
  60637. z: number;
  60638. private static _UpReadOnly;
  60639. /**
  60640. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60641. * @param x defines the first coordinates (on X axis)
  60642. * @param y defines the second coordinates (on Y axis)
  60643. * @param z defines the third coordinates (on Z axis)
  60644. */
  60645. constructor(
  60646. /**
  60647. * Defines the first coordinates (on X axis)
  60648. */
  60649. x?: number,
  60650. /**
  60651. * Defines the second coordinates (on Y axis)
  60652. */
  60653. y?: number,
  60654. /**
  60655. * Defines the third coordinates (on Z axis)
  60656. */
  60657. z?: number);
  60658. /**
  60659. * Creates a string representation of the Vector3
  60660. * @returns a string with the Vector3 coordinates.
  60661. */
  60662. toString(): string;
  60663. /**
  60664. * Gets the class name
  60665. * @returns the string "Vector3"
  60666. */
  60667. getClassName(): string;
  60668. /**
  60669. * Creates the Vector3 hash code
  60670. * @returns a number which tends to be unique between Vector3 instances
  60671. */
  60672. getHashCode(): number;
  60673. /**
  60674. * Creates an array containing three elements : the coordinates of the Vector3
  60675. * @returns a new array of numbers
  60676. */
  60677. asArray(): number[];
  60678. /**
  60679. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60680. * @param array defines the destination array
  60681. * @param index defines the offset in the destination array
  60682. * @returns the current Vector3
  60683. */
  60684. toArray(array: FloatArray, index?: number): Vector3;
  60685. /**
  60686. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60687. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60688. */
  60689. toQuaternion(): Quaternion;
  60690. /**
  60691. * Adds the given vector to the current Vector3
  60692. * @param otherVector defines the second operand
  60693. * @returns the current updated Vector3
  60694. */
  60695. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60696. /**
  60697. * Adds the given coordinates to the current Vector3
  60698. * @param x defines the x coordinate of the operand
  60699. * @param y defines the y coordinate of the operand
  60700. * @param z defines the z coordinate of the operand
  60701. * @returns the current updated Vector3
  60702. */
  60703. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60704. /**
  60705. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60706. * @param otherVector defines the second operand
  60707. * @returns the resulting Vector3
  60708. */
  60709. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60710. /**
  60711. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60712. * @param otherVector defines the second operand
  60713. * @param result defines the Vector3 object where to store the result
  60714. * @returns the current Vector3
  60715. */
  60716. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60717. /**
  60718. * Subtract the given vector from the current Vector3
  60719. * @param otherVector defines the second operand
  60720. * @returns the current updated Vector3
  60721. */
  60722. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60723. /**
  60724. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60725. * @param otherVector defines the second operand
  60726. * @returns the resulting Vector3
  60727. */
  60728. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60729. /**
  60730. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60731. * @param otherVector defines the second operand
  60732. * @param result defines the Vector3 object where to store the result
  60733. * @returns the current Vector3
  60734. */
  60735. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60736. /**
  60737. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60738. * @param x defines the x coordinate of the operand
  60739. * @param y defines the y coordinate of the operand
  60740. * @param z defines the z coordinate of the operand
  60741. * @returns the resulting Vector3
  60742. */
  60743. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60744. /**
  60745. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60746. * @param x defines the x coordinate of the operand
  60747. * @param y defines the y coordinate of the operand
  60748. * @param z defines the z coordinate of the operand
  60749. * @param result defines the Vector3 object where to store the result
  60750. * @returns the current Vector3
  60751. */
  60752. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60753. /**
  60754. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60755. * @returns a new Vector3
  60756. */
  60757. negate(): Vector3;
  60758. /**
  60759. * Multiplies the Vector3 coordinates by the float "scale"
  60760. * @param scale defines the multiplier factor
  60761. * @returns the current updated Vector3
  60762. */
  60763. scaleInPlace(scale: number): Vector3;
  60764. /**
  60765. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60766. * @param scale defines the multiplier factor
  60767. * @returns a new Vector3
  60768. */
  60769. scale(scale: number): Vector3;
  60770. /**
  60771. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60772. * @param scale defines the multiplier factor
  60773. * @param result defines the Vector3 object where to store the result
  60774. * @returns the current Vector3
  60775. */
  60776. scaleToRef(scale: number, result: Vector3): Vector3;
  60777. /**
  60778. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60779. * @param scale defines the scale factor
  60780. * @param result defines the Vector3 object where to store the result
  60781. * @returns the unmodified current Vector3
  60782. */
  60783. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60784. /**
  60785. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60786. * @param otherVector defines the second operand
  60787. * @returns true if both vectors are equals
  60788. */
  60789. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60790. /**
  60791. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60792. * @param otherVector defines the second operand
  60793. * @param epsilon defines the minimal distance to define values as equals
  60794. * @returns true if both vectors are distant less than epsilon
  60795. */
  60796. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60797. /**
  60798. * Returns true if the current Vector3 coordinates equals the given floats
  60799. * @param x defines the x coordinate of the operand
  60800. * @param y defines the y coordinate of the operand
  60801. * @param z defines the z coordinate of the operand
  60802. * @returns true if both vectors are equals
  60803. */
  60804. equalsToFloats(x: number, y: number, z: number): boolean;
  60805. /**
  60806. * Multiplies the current Vector3 coordinates by the given ones
  60807. * @param otherVector defines the second operand
  60808. * @returns the current updated Vector3
  60809. */
  60810. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60811. /**
  60812. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60813. * @param otherVector defines the second operand
  60814. * @returns the new Vector3
  60815. */
  60816. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60817. /**
  60818. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60819. * @param otherVector defines the second operand
  60820. * @param result defines the Vector3 object where to store the result
  60821. * @returns the current Vector3
  60822. */
  60823. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60824. /**
  60825. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60826. * @param x defines the x coordinate of the operand
  60827. * @param y defines the y coordinate of the operand
  60828. * @param z defines the z coordinate of the operand
  60829. * @returns the new Vector3
  60830. */
  60831. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60832. /**
  60833. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60834. * @param otherVector defines the second operand
  60835. * @returns the new Vector3
  60836. */
  60837. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60838. /**
  60839. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60840. * @param otherVector defines the second operand
  60841. * @param result defines the Vector3 object where to store the result
  60842. * @returns the current Vector3
  60843. */
  60844. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60845. /**
  60846. * Divides the current Vector3 coordinates by the given ones.
  60847. * @param otherVector defines the second operand
  60848. * @returns the current updated Vector3
  60849. */
  60850. divideInPlace(otherVector: Vector3): Vector3;
  60851. /**
  60852. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60853. * @param other defines the second operand
  60854. * @returns the current updated Vector3
  60855. */
  60856. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60857. /**
  60858. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60859. * @param other defines the second operand
  60860. * @returns the current updated Vector3
  60861. */
  60862. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60863. /**
  60864. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  60865. * @param x defines the x coordinate of the operand
  60866. * @param y defines the y coordinate of the operand
  60867. * @param z defines the z coordinate of the operand
  60868. * @returns the current updated Vector3
  60869. */
  60870. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60871. /**
  60872. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  60873. * @param x defines the x coordinate of the operand
  60874. * @param y defines the y coordinate of the operand
  60875. * @param z defines the z coordinate of the operand
  60876. * @returns the current updated Vector3
  60877. */
  60878. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60879. /**
  60880. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  60881. * Check if is non uniform within a certain amount of decimal places to account for this
  60882. * @param epsilon the amount the values can differ
  60883. * @returns if the the vector is non uniform to a certain number of decimal places
  60884. */
  60885. isNonUniformWithinEpsilon(epsilon: number): boolean;
  60886. /**
  60887. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  60888. */
  60889. readonly isNonUniform: boolean;
  60890. /**
  60891. * Gets a new Vector3 from current Vector3 floored values
  60892. * @returns a new Vector3
  60893. */
  60894. floor(): Vector3;
  60895. /**
  60896. * Gets a new Vector3 from current Vector3 floored values
  60897. * @returns a new Vector3
  60898. */
  60899. fract(): Vector3;
  60900. /**
  60901. * Gets the length of the Vector3
  60902. * @returns the length of the Vecto3
  60903. */
  60904. length(): number;
  60905. /**
  60906. * Gets the squared length of the Vector3
  60907. * @returns squared length of the Vector3
  60908. */
  60909. lengthSquared(): number;
  60910. /**
  60911. * Normalize the current Vector3.
  60912. * Please note that this is an in place operation.
  60913. * @returns the current updated Vector3
  60914. */
  60915. normalize(): Vector3;
  60916. /**
  60917. * Reorders the x y z properties of the vector in place
  60918. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  60919. * @returns the current updated vector
  60920. */
  60921. reorderInPlace(order: string): this;
  60922. /**
  60923. * Rotates the vector around 0,0,0 by a quaternion
  60924. * @param quaternion the rotation quaternion
  60925. * @param result vector to store the result
  60926. * @returns the resulting vector
  60927. */
  60928. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  60929. /**
  60930. * Rotates a vector around a given point
  60931. * @param quaternion the rotation quaternion
  60932. * @param point the point to rotate around
  60933. * @param result vector to store the result
  60934. * @returns the resulting vector
  60935. */
  60936. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  60937. /**
  60938. * Normalize the current Vector3 with the given input length.
  60939. * Please note that this is an in place operation.
  60940. * @param len the length of the vector
  60941. * @returns the current updated Vector3
  60942. */
  60943. normalizeFromLength(len: number): Vector3;
  60944. /**
  60945. * Normalize the current Vector3 to a new vector
  60946. * @returns the new Vector3
  60947. */
  60948. normalizeToNew(): Vector3;
  60949. /**
  60950. * Normalize the current Vector3 to the reference
  60951. * @param reference define the Vector3 to update
  60952. * @returns the updated Vector3
  60953. */
  60954. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  60955. /**
  60956. * Creates a new Vector3 copied from the current Vector3
  60957. * @returns the new Vector3
  60958. */
  60959. clone(): Vector3;
  60960. /**
  60961. * Copies the given vector coordinates to the current Vector3 ones
  60962. * @param source defines the source Vector3
  60963. * @returns the current updated Vector3
  60964. */
  60965. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  60966. /**
  60967. * Copies the given floats to the current Vector3 coordinates
  60968. * @param x defines the x coordinate of the operand
  60969. * @param y defines the y coordinate of the operand
  60970. * @param z defines the z coordinate of the operand
  60971. * @returns the current updated Vector3
  60972. */
  60973. copyFromFloats(x: number, y: number, z: number): Vector3;
  60974. /**
  60975. * Copies the given floats to the current Vector3 coordinates
  60976. * @param x defines the x coordinate of the operand
  60977. * @param y defines the y coordinate of the operand
  60978. * @param z defines the z coordinate of the operand
  60979. * @returns the current updated Vector3
  60980. */
  60981. set(x: number, y: number, z: number): Vector3;
  60982. /**
  60983. * Copies the given float to the current Vector3 coordinates
  60984. * @param v defines the x, y and z coordinates of the operand
  60985. * @returns the current updated Vector3
  60986. */
  60987. setAll(v: number): Vector3;
  60988. /**
  60989. * Get the clip factor between two vectors
  60990. * @param vector0 defines the first operand
  60991. * @param vector1 defines the second operand
  60992. * @param axis defines the axis to use
  60993. * @param size defines the size along the axis
  60994. * @returns the clip factor
  60995. */
  60996. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  60997. /**
  60998. * Get angle between two vectors
  60999. * @param vector0 angle between vector0 and vector1
  61000. * @param vector1 angle between vector0 and vector1
  61001. * @param normal direction of the normal
  61002. * @return the angle between vector0 and vector1
  61003. */
  61004. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61005. /**
  61006. * Returns a new Vector3 set from the index "offset" of the given array
  61007. * @param array defines the source array
  61008. * @param offset defines the offset in the source array
  61009. * @returns the new Vector3
  61010. */
  61011. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61012. /**
  61013. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61014. * This function is deprecated. Use FromArray instead
  61015. * @param array defines the source array
  61016. * @param offset defines the offset in the source array
  61017. * @returns the new Vector3
  61018. */
  61019. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61020. /**
  61021. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61022. * @param array defines the source array
  61023. * @param offset defines the offset in the source array
  61024. * @param result defines the Vector3 where to store the result
  61025. */
  61026. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61027. /**
  61028. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61029. * This function is deprecated. Use FromArrayToRef instead.
  61030. * @param array defines the source array
  61031. * @param offset defines the offset in the source array
  61032. * @param result defines the Vector3 where to store the result
  61033. */
  61034. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61035. /**
  61036. * Sets the given vector "result" with the given floats.
  61037. * @param x defines the x coordinate of the source
  61038. * @param y defines the y coordinate of the source
  61039. * @param z defines the z coordinate of the source
  61040. * @param result defines the Vector3 where to store the result
  61041. */
  61042. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61043. /**
  61044. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61045. * @returns a new empty Vector3
  61046. */
  61047. static Zero(): Vector3;
  61048. /**
  61049. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61050. * @returns a new unit Vector3
  61051. */
  61052. static One(): Vector3;
  61053. /**
  61054. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61055. * @returns a new up Vector3
  61056. */
  61057. static Up(): Vector3;
  61058. /**
  61059. * Gets a up Vector3 that must not be updated
  61060. */
  61061. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61062. /**
  61063. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61064. * @returns a new down Vector3
  61065. */
  61066. static Down(): Vector3;
  61067. /**
  61068. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61069. * @returns a new forward Vector3
  61070. */
  61071. static Forward(): Vector3;
  61072. /**
  61073. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61074. * @returns a new forward Vector3
  61075. */
  61076. static Backward(): Vector3;
  61077. /**
  61078. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61079. * @returns a new right Vector3
  61080. */
  61081. static Right(): Vector3;
  61082. /**
  61083. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61084. * @returns a new left Vector3
  61085. */
  61086. static Left(): Vector3;
  61087. /**
  61088. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61089. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61090. * @param vector defines the Vector3 to transform
  61091. * @param transformation defines the transformation matrix
  61092. * @returns the transformed Vector3
  61093. */
  61094. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61095. /**
  61096. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61097. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61098. * @param vector defines the Vector3 to transform
  61099. * @param transformation defines the transformation matrix
  61100. * @param result defines the Vector3 where to store the result
  61101. */
  61102. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61103. /**
  61104. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61105. * This method computes tranformed coordinates only, not transformed direction vectors
  61106. * @param x define the x coordinate of the source vector
  61107. * @param y define the y coordinate of the source vector
  61108. * @param z define the z coordinate of the source vector
  61109. * @param transformation defines the transformation matrix
  61110. * @param result defines the Vector3 where to store the result
  61111. */
  61112. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61113. /**
  61114. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61115. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61116. * @param vector defines the Vector3 to transform
  61117. * @param transformation defines the transformation matrix
  61118. * @returns the new Vector3
  61119. */
  61120. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61121. /**
  61122. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61123. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61124. * @param vector defines the Vector3 to transform
  61125. * @param transformation defines the transformation matrix
  61126. * @param result defines the Vector3 where to store the result
  61127. */
  61128. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61129. /**
  61130. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61131. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61132. * @param x define the x coordinate of the source vector
  61133. * @param y define the y coordinate of the source vector
  61134. * @param z define the z coordinate of the source vector
  61135. * @param transformation defines the transformation matrix
  61136. * @param result defines the Vector3 where to store the result
  61137. */
  61138. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61139. /**
  61140. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61141. * @param value1 defines the first control point
  61142. * @param value2 defines the second control point
  61143. * @param value3 defines the third control point
  61144. * @param value4 defines the fourth control point
  61145. * @param amount defines the amount on the spline to use
  61146. * @returns the new Vector3
  61147. */
  61148. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61149. /**
  61150. * 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"
  61151. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61152. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61153. * @param value defines the current value
  61154. * @param min defines the lower range value
  61155. * @param max defines the upper range value
  61156. * @returns the new Vector3
  61157. */
  61158. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61159. /**
  61160. * 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"
  61161. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61162. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61163. * @param value defines the current value
  61164. * @param min defines the lower range value
  61165. * @param max defines the upper range value
  61166. * @param result defines the Vector3 where to store the result
  61167. */
  61168. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61169. /**
  61170. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61171. * @param value1 defines the first control point
  61172. * @param tangent1 defines the first tangent vector
  61173. * @param value2 defines the second control point
  61174. * @param tangent2 defines the second tangent vector
  61175. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61176. * @returns the new Vector3
  61177. */
  61178. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61179. /**
  61180. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61181. * @param start defines the start value
  61182. * @param end defines the end value
  61183. * @param amount max defines amount between both (between 0 and 1)
  61184. * @returns the new Vector3
  61185. */
  61186. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61187. /**
  61188. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61189. * @param start defines the start value
  61190. * @param end defines the end value
  61191. * @param amount max defines amount between both (between 0 and 1)
  61192. * @param result defines the Vector3 where to store the result
  61193. */
  61194. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61195. /**
  61196. * Returns the dot product (float) between the vectors "left" and "right"
  61197. * @param left defines the left operand
  61198. * @param right defines the right operand
  61199. * @returns the dot product
  61200. */
  61201. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61202. /**
  61203. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61204. * The cross product is then orthogonal to both "left" and "right"
  61205. * @param left defines the left operand
  61206. * @param right defines the right operand
  61207. * @returns the cross product
  61208. */
  61209. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61210. /**
  61211. * Sets the given vector "result" with the cross product of "left" and "right"
  61212. * The cross product is then orthogonal to both "left" and "right"
  61213. * @param left defines the left operand
  61214. * @param right defines the right operand
  61215. * @param result defines the Vector3 where to store the result
  61216. */
  61217. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61218. /**
  61219. * Returns a new Vector3 as the normalization of the given vector
  61220. * @param vector defines the Vector3 to normalize
  61221. * @returns the new Vector3
  61222. */
  61223. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61224. /**
  61225. * Sets the given vector "result" with the normalization of the given first vector
  61226. * @param vector defines the Vector3 to normalize
  61227. * @param result defines the Vector3 where to store the result
  61228. */
  61229. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61230. /**
  61231. * Project a Vector3 onto screen space
  61232. * @param vector defines the Vector3 to project
  61233. * @param world defines the world matrix to use
  61234. * @param transform defines the transform (view x projection) matrix to use
  61235. * @param viewport defines the screen viewport to use
  61236. * @returns the new Vector3
  61237. */
  61238. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61239. /** @hidden */
  61240. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61241. /**
  61242. * Unproject from screen space to object space
  61243. * @param source defines the screen space Vector3 to use
  61244. * @param viewportWidth defines the current width of the viewport
  61245. * @param viewportHeight defines the current height of the viewport
  61246. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61247. * @param transform defines the transform (view x projection) matrix to use
  61248. * @returns the new Vector3
  61249. */
  61250. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61251. /**
  61252. * Unproject from screen space to object space
  61253. * @param source defines the screen space Vector3 to use
  61254. * @param viewportWidth defines the current width of the viewport
  61255. * @param viewportHeight defines the current height of the viewport
  61256. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61257. * @param view defines the view matrix to use
  61258. * @param projection defines the projection matrix to use
  61259. * @returns the new Vector3
  61260. */
  61261. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61262. /**
  61263. * Unproject from screen space to object space
  61264. * @param source defines the screen space Vector3 to use
  61265. * @param viewportWidth defines the current width of the viewport
  61266. * @param viewportHeight defines the current height of the viewport
  61267. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61268. * @param view defines the view matrix to use
  61269. * @param projection defines the projection matrix to use
  61270. * @param result defines the Vector3 where to store the result
  61271. */
  61272. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61273. /**
  61274. * Unproject from screen space to object space
  61275. * @param sourceX defines the screen space x coordinate to use
  61276. * @param sourceY defines the screen space y coordinate to use
  61277. * @param sourceZ defines the screen space z coordinate to use
  61278. * @param viewportWidth defines the current width of the viewport
  61279. * @param viewportHeight defines the current height of the viewport
  61280. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61281. * @param view defines the view matrix to use
  61282. * @param projection defines the projection matrix to use
  61283. * @param result defines the Vector3 where to store the result
  61284. */
  61285. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61286. /**
  61287. * Gets the minimal coordinate values between two Vector3
  61288. * @param left defines the first operand
  61289. * @param right defines the second operand
  61290. * @returns the new Vector3
  61291. */
  61292. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61293. /**
  61294. * Gets the maximal coordinate values between two Vector3
  61295. * @param left defines the first operand
  61296. * @param right defines the second operand
  61297. * @returns the new Vector3
  61298. */
  61299. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61300. /**
  61301. * Returns the distance between the vectors "value1" and "value2"
  61302. * @param value1 defines the first operand
  61303. * @param value2 defines the second operand
  61304. * @returns the distance
  61305. */
  61306. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61307. /**
  61308. * Returns the squared distance between the vectors "value1" and "value2"
  61309. * @param value1 defines the first operand
  61310. * @param value2 defines the second operand
  61311. * @returns the squared distance
  61312. */
  61313. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61314. /**
  61315. * Returns a new Vector3 located at the center between "value1" and "value2"
  61316. * @param value1 defines the first operand
  61317. * @param value2 defines the second operand
  61318. * @returns the new Vector3
  61319. */
  61320. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61321. /**
  61322. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61323. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61324. * to something in order to rotate it from its local system to the given target system
  61325. * Note: axis1, axis2 and axis3 are normalized during this operation
  61326. * @param axis1 defines the first axis
  61327. * @param axis2 defines the second axis
  61328. * @param axis3 defines the third axis
  61329. * @returns a new Vector3
  61330. */
  61331. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61332. /**
  61333. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61334. * @param axis1 defines the first axis
  61335. * @param axis2 defines the second axis
  61336. * @param axis3 defines the third axis
  61337. * @param ref defines the Vector3 where to store the result
  61338. */
  61339. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61340. }
  61341. /**
  61342. * Vector4 class created for EulerAngle class conversion to Quaternion
  61343. */
  61344. export class Vector4 {
  61345. /** x value of the vector */
  61346. x: number;
  61347. /** y value of the vector */
  61348. y: number;
  61349. /** z value of the vector */
  61350. z: number;
  61351. /** w value of the vector */
  61352. w: number;
  61353. /**
  61354. * Creates a Vector4 object from the given floats.
  61355. * @param x x value of the vector
  61356. * @param y y value of the vector
  61357. * @param z z value of the vector
  61358. * @param w w value of the vector
  61359. */
  61360. constructor(
  61361. /** x value of the vector */
  61362. x: number,
  61363. /** y value of the vector */
  61364. y: number,
  61365. /** z value of the vector */
  61366. z: number,
  61367. /** w value of the vector */
  61368. w: number);
  61369. /**
  61370. * Returns the string with the Vector4 coordinates.
  61371. * @returns a string containing all the vector values
  61372. */
  61373. toString(): string;
  61374. /**
  61375. * Returns the string "Vector4".
  61376. * @returns "Vector4"
  61377. */
  61378. getClassName(): string;
  61379. /**
  61380. * Returns the Vector4 hash code.
  61381. * @returns a unique hash code
  61382. */
  61383. getHashCode(): number;
  61384. /**
  61385. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61386. * @returns the resulting array
  61387. */
  61388. asArray(): number[];
  61389. /**
  61390. * Populates the given array from the given index with the Vector4 coordinates.
  61391. * @param array array to populate
  61392. * @param index index of the array to start at (default: 0)
  61393. * @returns the Vector4.
  61394. */
  61395. toArray(array: FloatArray, index?: number): Vector4;
  61396. /**
  61397. * Adds the given vector to the current Vector4.
  61398. * @param otherVector the vector to add
  61399. * @returns the updated Vector4.
  61400. */
  61401. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61402. /**
  61403. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61404. * @param otherVector the vector to add
  61405. * @returns the resulting vector
  61406. */
  61407. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61408. /**
  61409. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61410. * @param otherVector the vector to add
  61411. * @param result the vector to store the result
  61412. * @returns the current Vector4.
  61413. */
  61414. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61415. /**
  61416. * Subtract in place the given vector from the current Vector4.
  61417. * @param otherVector the vector to subtract
  61418. * @returns the updated Vector4.
  61419. */
  61420. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61421. /**
  61422. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61423. * @param otherVector the vector to add
  61424. * @returns the new vector with the result
  61425. */
  61426. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61427. /**
  61428. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61429. * @param otherVector the vector to subtract
  61430. * @param result the vector to store the result
  61431. * @returns the current Vector4.
  61432. */
  61433. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61434. /**
  61435. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61436. */
  61437. /**
  61438. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61439. * @param x value to subtract
  61440. * @param y value to subtract
  61441. * @param z value to subtract
  61442. * @param w value to subtract
  61443. * @returns new vector containing the result
  61444. */
  61445. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61446. /**
  61447. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61448. * @param x value to subtract
  61449. * @param y value to subtract
  61450. * @param z value to subtract
  61451. * @param w value to subtract
  61452. * @param result the vector to store the result in
  61453. * @returns the current Vector4.
  61454. */
  61455. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61456. /**
  61457. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61458. * @returns a new vector with the negated values
  61459. */
  61460. negate(): Vector4;
  61461. /**
  61462. * Multiplies the current Vector4 coordinates by scale (float).
  61463. * @param scale the number to scale with
  61464. * @returns the updated Vector4.
  61465. */
  61466. scaleInPlace(scale: number): Vector4;
  61467. /**
  61468. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61469. * @param scale the number to scale with
  61470. * @returns a new vector with the result
  61471. */
  61472. scale(scale: number): Vector4;
  61473. /**
  61474. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61475. * @param scale the number to scale with
  61476. * @param result a vector to store the result in
  61477. * @returns the current Vector4.
  61478. */
  61479. scaleToRef(scale: number, result: Vector4): Vector4;
  61480. /**
  61481. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61482. * @param scale defines the scale factor
  61483. * @param result defines the Vector4 object where to store the result
  61484. * @returns the unmodified current Vector4
  61485. */
  61486. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61487. /**
  61488. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61489. * @param otherVector the vector to compare against
  61490. * @returns true if they are equal
  61491. */
  61492. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61493. /**
  61494. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61495. * @param otherVector vector to compare against
  61496. * @param epsilon (Default: very small number)
  61497. * @returns true if they are equal
  61498. */
  61499. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61500. /**
  61501. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61502. * @param x x value to compare against
  61503. * @param y y value to compare against
  61504. * @param z z value to compare against
  61505. * @param w w value to compare against
  61506. * @returns true if equal
  61507. */
  61508. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61509. /**
  61510. * Multiplies in place the current Vector4 by the given one.
  61511. * @param otherVector vector to multiple with
  61512. * @returns the updated Vector4.
  61513. */
  61514. multiplyInPlace(otherVector: Vector4): Vector4;
  61515. /**
  61516. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61517. * @param otherVector vector to multiple with
  61518. * @returns resulting new vector
  61519. */
  61520. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61521. /**
  61522. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61523. * @param otherVector vector to multiple with
  61524. * @param result vector to store the result
  61525. * @returns the current Vector4.
  61526. */
  61527. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61528. /**
  61529. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61530. * @param x x value multiply with
  61531. * @param y y value multiply with
  61532. * @param z z value multiply with
  61533. * @param w w value multiply with
  61534. * @returns resulting new vector
  61535. */
  61536. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61537. /**
  61538. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61539. * @param otherVector vector to devide with
  61540. * @returns resulting new vector
  61541. */
  61542. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61543. /**
  61544. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61545. * @param otherVector vector to devide with
  61546. * @param result vector to store the result
  61547. * @returns the current Vector4.
  61548. */
  61549. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61550. /**
  61551. * Divides the current Vector3 coordinates by the given ones.
  61552. * @param otherVector vector to devide with
  61553. * @returns the updated Vector3.
  61554. */
  61555. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61556. /**
  61557. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61558. * @param other defines the second operand
  61559. * @returns the current updated Vector4
  61560. */
  61561. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61562. /**
  61563. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61564. * @param other defines the second operand
  61565. * @returns the current updated Vector4
  61566. */
  61567. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61568. /**
  61569. * Gets a new Vector4 from current Vector4 floored values
  61570. * @returns a new Vector4
  61571. */
  61572. floor(): Vector4;
  61573. /**
  61574. * Gets a new Vector4 from current Vector3 floored values
  61575. * @returns a new Vector4
  61576. */
  61577. fract(): Vector4;
  61578. /**
  61579. * Returns the Vector4 length (float).
  61580. * @returns the length
  61581. */
  61582. length(): number;
  61583. /**
  61584. * Returns the Vector4 squared length (float).
  61585. * @returns the length squared
  61586. */
  61587. lengthSquared(): number;
  61588. /**
  61589. * Normalizes in place the Vector4.
  61590. * @returns the updated Vector4.
  61591. */
  61592. normalize(): Vector4;
  61593. /**
  61594. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61595. * @returns this converted to a new vector3
  61596. */
  61597. toVector3(): Vector3;
  61598. /**
  61599. * Returns a new Vector4 copied from the current one.
  61600. * @returns the new cloned vector
  61601. */
  61602. clone(): Vector4;
  61603. /**
  61604. * Updates the current Vector4 with the given one coordinates.
  61605. * @param source the source vector to copy from
  61606. * @returns the updated Vector4.
  61607. */
  61608. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61609. /**
  61610. * Updates the current Vector4 coordinates with the given floats.
  61611. * @param x float to copy from
  61612. * @param y float to copy from
  61613. * @param z float to copy from
  61614. * @param w float to copy from
  61615. * @returns the updated Vector4.
  61616. */
  61617. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61618. /**
  61619. * Updates the current Vector4 coordinates with the given floats.
  61620. * @param x float to set from
  61621. * @param y float to set from
  61622. * @param z float to set from
  61623. * @param w float to set from
  61624. * @returns the updated Vector4.
  61625. */
  61626. set(x: number, y: number, z: number, w: number): Vector4;
  61627. /**
  61628. * Copies the given float to the current Vector3 coordinates
  61629. * @param v defines the x, y, z and w coordinates of the operand
  61630. * @returns the current updated Vector3
  61631. */
  61632. setAll(v: number): Vector4;
  61633. /**
  61634. * Returns a new Vector4 set from the starting index of the given array.
  61635. * @param array the array to pull values from
  61636. * @param offset the offset into the array to start at
  61637. * @returns the new vector
  61638. */
  61639. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61640. /**
  61641. * Updates the given vector "result" from the starting index of the given array.
  61642. * @param array the array to pull values from
  61643. * @param offset the offset into the array to start at
  61644. * @param result the vector to store the result in
  61645. */
  61646. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61647. /**
  61648. * Updates the given vector "result" from the starting index of the given Float32Array.
  61649. * @param array the array to pull values from
  61650. * @param offset the offset into the array to start at
  61651. * @param result the vector to store the result in
  61652. */
  61653. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61654. /**
  61655. * Updates the given vector "result" coordinates from the given floats.
  61656. * @param x float to set from
  61657. * @param y float to set from
  61658. * @param z float to set from
  61659. * @param w float to set from
  61660. * @param result the vector to the floats in
  61661. */
  61662. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61663. /**
  61664. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61665. * @returns the new vector
  61666. */
  61667. static Zero(): Vector4;
  61668. /**
  61669. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61670. * @returns the new vector
  61671. */
  61672. static One(): Vector4;
  61673. /**
  61674. * Returns a new normalized Vector4 from the given one.
  61675. * @param vector the vector to normalize
  61676. * @returns the vector
  61677. */
  61678. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61679. /**
  61680. * Updates the given vector "result" from the normalization of the given one.
  61681. * @param vector the vector to normalize
  61682. * @param result the vector to store the result in
  61683. */
  61684. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61685. /**
  61686. * Returns a vector with the minimum values from the left and right vectors
  61687. * @param left left vector to minimize
  61688. * @param right right vector to minimize
  61689. * @returns a new vector with the minimum of the left and right vector values
  61690. */
  61691. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61692. /**
  61693. * Returns a vector with the maximum values from the left and right vectors
  61694. * @param left left vector to maximize
  61695. * @param right right vector to maximize
  61696. * @returns a new vector with the maximum of the left and right vector values
  61697. */
  61698. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61699. /**
  61700. * Returns the distance (float) between the vectors "value1" and "value2".
  61701. * @param value1 value to calulate the distance between
  61702. * @param value2 value to calulate the distance between
  61703. * @return the distance between the two vectors
  61704. */
  61705. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61706. /**
  61707. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61708. * @param value1 value to calulate the distance between
  61709. * @param value2 value to calulate the distance between
  61710. * @return the distance between the two vectors squared
  61711. */
  61712. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61713. /**
  61714. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61715. * @param value1 value to calulate the center between
  61716. * @param value2 value to calulate the center between
  61717. * @return the center between the two vectors
  61718. */
  61719. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61720. /**
  61721. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61722. * This methods computes transformed normalized direction vectors only.
  61723. * @param vector the vector to transform
  61724. * @param transformation the transformation matrix to apply
  61725. * @returns the new vector
  61726. */
  61727. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61728. /**
  61729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61730. * This methods computes transformed normalized direction vectors only.
  61731. * @param vector the vector to transform
  61732. * @param transformation the transformation matrix to apply
  61733. * @param result the vector to store the result in
  61734. */
  61735. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61736. /**
  61737. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61738. * This methods computes transformed normalized direction vectors only.
  61739. * @param x value to transform
  61740. * @param y value to transform
  61741. * @param z value to transform
  61742. * @param w value to transform
  61743. * @param transformation the transformation matrix to apply
  61744. * @param result the vector to store the results in
  61745. */
  61746. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61747. /**
  61748. * Creates a new Vector4 from a Vector3
  61749. * @param source defines the source data
  61750. * @param w defines the 4th component (default is 0)
  61751. * @returns a new Vector4
  61752. */
  61753. static FromVector3(source: Vector3, w?: number): Vector4;
  61754. }
  61755. /**
  61756. * Interface for the size containing width and height
  61757. */
  61758. export interface ISize {
  61759. /**
  61760. * Width
  61761. */
  61762. width: number;
  61763. /**
  61764. * Heighht
  61765. */
  61766. height: number;
  61767. }
  61768. /**
  61769. * Size containing widht and height
  61770. */
  61771. export class Size implements ISize {
  61772. /**
  61773. * Width
  61774. */
  61775. width: number;
  61776. /**
  61777. * Height
  61778. */
  61779. height: number;
  61780. /**
  61781. * Creates a Size object from the given width and height (floats).
  61782. * @param width width of the new size
  61783. * @param height height of the new size
  61784. */
  61785. constructor(width: number, height: number);
  61786. /**
  61787. * Returns a string with the Size width and height
  61788. * @returns a string with the Size width and height
  61789. */
  61790. toString(): string;
  61791. /**
  61792. * "Size"
  61793. * @returns the string "Size"
  61794. */
  61795. getClassName(): string;
  61796. /**
  61797. * Returns the Size hash code.
  61798. * @returns a hash code for a unique width and height
  61799. */
  61800. getHashCode(): number;
  61801. /**
  61802. * Updates the current size from the given one.
  61803. * @param src the given size
  61804. */
  61805. copyFrom(src: Size): void;
  61806. /**
  61807. * Updates in place the current Size from the given floats.
  61808. * @param width width of the new size
  61809. * @param height height of the new size
  61810. * @returns the updated Size.
  61811. */
  61812. copyFromFloats(width: number, height: number): Size;
  61813. /**
  61814. * Updates in place the current Size from the given floats.
  61815. * @param width width to set
  61816. * @param height height to set
  61817. * @returns the updated Size.
  61818. */
  61819. set(width: number, height: number): Size;
  61820. /**
  61821. * Multiplies the width and height by numbers
  61822. * @param w factor to multiple the width by
  61823. * @param h factor to multiple the height by
  61824. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61825. */
  61826. multiplyByFloats(w: number, h: number): Size;
  61827. /**
  61828. * Clones the size
  61829. * @returns a new Size copied from the given one.
  61830. */
  61831. clone(): Size;
  61832. /**
  61833. * True if the current Size and the given one width and height are strictly equal.
  61834. * @param other the other size to compare against
  61835. * @returns True if the current Size and the given one width and height are strictly equal.
  61836. */
  61837. equals(other: Size): boolean;
  61838. /**
  61839. * The surface of the Size : width * height (float).
  61840. */
  61841. readonly surface: number;
  61842. /**
  61843. * Create a new size of zero
  61844. * @returns a new Size set to (0.0, 0.0)
  61845. */
  61846. static Zero(): Size;
  61847. /**
  61848. * Sums the width and height of two sizes
  61849. * @param otherSize size to add to this size
  61850. * @returns a new Size set as the addition result of the current Size and the given one.
  61851. */
  61852. add(otherSize: Size): Size;
  61853. /**
  61854. * Subtracts the width and height of two
  61855. * @param otherSize size to subtract to this size
  61856. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61857. */
  61858. subtract(otherSize: Size): Size;
  61859. /**
  61860. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  61861. * @param start starting size to lerp between
  61862. * @param end end size to lerp between
  61863. * @param amount amount to lerp between the start and end values
  61864. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  61865. */
  61866. static Lerp(start: Size, end: Size, amount: number): Size;
  61867. }
  61868. /**
  61869. * Class used to store quaternion data
  61870. * @see https://en.wikipedia.org/wiki/Quaternion
  61871. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  61872. */
  61873. export class Quaternion {
  61874. /** defines the first component (0 by default) */
  61875. x: number;
  61876. /** defines the second component (0 by default) */
  61877. y: number;
  61878. /** defines the third component (0 by default) */
  61879. z: number;
  61880. /** defines the fourth component (1.0 by default) */
  61881. w: number;
  61882. /**
  61883. * Creates a new Quaternion from the given floats
  61884. * @param x defines the first component (0 by default)
  61885. * @param y defines the second component (0 by default)
  61886. * @param z defines the third component (0 by default)
  61887. * @param w defines the fourth component (1.0 by default)
  61888. */
  61889. constructor(
  61890. /** defines the first component (0 by default) */
  61891. x?: number,
  61892. /** defines the second component (0 by default) */
  61893. y?: number,
  61894. /** defines the third component (0 by default) */
  61895. z?: number,
  61896. /** defines the fourth component (1.0 by default) */
  61897. w?: number);
  61898. /**
  61899. * Gets a string representation for the current quaternion
  61900. * @returns a string with the Quaternion coordinates
  61901. */
  61902. toString(): string;
  61903. /**
  61904. * Gets the class name of the quaternion
  61905. * @returns the string "Quaternion"
  61906. */
  61907. getClassName(): string;
  61908. /**
  61909. * Gets a hash code for this quaternion
  61910. * @returns the quaternion hash code
  61911. */
  61912. getHashCode(): number;
  61913. /**
  61914. * Copy the quaternion to an array
  61915. * @returns a new array populated with 4 elements from the quaternion coordinates
  61916. */
  61917. asArray(): number[];
  61918. /**
  61919. * Check if two quaternions are equals
  61920. * @param otherQuaternion defines the second operand
  61921. * @return true if the current quaternion and the given one coordinates are strictly equals
  61922. */
  61923. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  61924. /**
  61925. * Clone the current quaternion
  61926. * @returns a new quaternion copied from the current one
  61927. */
  61928. clone(): Quaternion;
  61929. /**
  61930. * Copy a quaternion to the current one
  61931. * @param other defines the other quaternion
  61932. * @returns the updated current quaternion
  61933. */
  61934. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  61935. /**
  61936. * Updates the current quaternion with the given float coordinates
  61937. * @param x defines the x coordinate
  61938. * @param y defines the y coordinate
  61939. * @param z defines the z coordinate
  61940. * @param w defines the w coordinate
  61941. * @returns the updated current quaternion
  61942. */
  61943. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  61944. /**
  61945. * Updates the current quaternion from the given float coordinates
  61946. * @param x defines the x coordinate
  61947. * @param y defines the y coordinate
  61948. * @param z defines the z coordinate
  61949. * @param w defines the w coordinate
  61950. * @returns the updated current quaternion
  61951. */
  61952. set(x: number, y: number, z: number, w: number): Quaternion;
  61953. /**
  61954. * Adds two quaternions
  61955. * @param other defines the second operand
  61956. * @returns a new quaternion as the addition result of the given one and the current quaternion
  61957. */
  61958. add(other: DeepImmutable<Quaternion>): Quaternion;
  61959. /**
  61960. * Add a quaternion to the current one
  61961. * @param other defines the quaternion to add
  61962. * @returns the current quaternion
  61963. */
  61964. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  61965. /**
  61966. * Subtract two quaternions
  61967. * @param other defines the second operand
  61968. * @returns a new quaternion as the subtraction result of the given one from the current one
  61969. */
  61970. subtract(other: Quaternion): Quaternion;
  61971. /**
  61972. * Multiplies the current quaternion by a scale factor
  61973. * @param value defines the scale factor
  61974. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  61975. */
  61976. scale(value: number): Quaternion;
  61977. /**
  61978. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  61979. * @param scale defines the scale factor
  61980. * @param result defines the Quaternion object where to store the result
  61981. * @returns the unmodified current quaternion
  61982. */
  61983. scaleToRef(scale: number, result: Quaternion): Quaternion;
  61984. /**
  61985. * Multiplies in place the current quaternion by a scale factor
  61986. * @param value defines the scale factor
  61987. * @returns the current modified quaternion
  61988. */
  61989. scaleInPlace(value: number): Quaternion;
  61990. /**
  61991. * Scale the current quaternion values by a factor and add the result to a given quaternion
  61992. * @param scale defines the scale factor
  61993. * @param result defines the Quaternion object where to store the result
  61994. * @returns the unmodified current quaternion
  61995. */
  61996. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  61997. /**
  61998. * Multiplies two quaternions
  61999. * @param q1 defines the second operand
  62000. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62001. */
  62002. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62003. /**
  62004. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62005. * @param q1 defines the second operand
  62006. * @param result defines the target quaternion
  62007. * @returns the current quaternion
  62008. */
  62009. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62010. /**
  62011. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62012. * @param q1 defines the second operand
  62013. * @returns the currentupdated quaternion
  62014. */
  62015. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62016. /**
  62017. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62018. * @param ref defines the target quaternion
  62019. * @returns the current quaternion
  62020. */
  62021. conjugateToRef(ref: Quaternion): Quaternion;
  62022. /**
  62023. * Conjugates in place (1-q) the current quaternion
  62024. * @returns the current updated quaternion
  62025. */
  62026. conjugateInPlace(): Quaternion;
  62027. /**
  62028. * Conjugates in place (1-q) the current quaternion
  62029. * @returns a new quaternion
  62030. */
  62031. conjugate(): Quaternion;
  62032. /**
  62033. * Gets length of current quaternion
  62034. * @returns the quaternion length (float)
  62035. */
  62036. length(): number;
  62037. /**
  62038. * Normalize in place the current quaternion
  62039. * @returns the current updated quaternion
  62040. */
  62041. normalize(): Quaternion;
  62042. /**
  62043. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62044. * @param order is a reserved parameter and is ignore for now
  62045. * @returns a new Vector3 containing the Euler angles
  62046. */
  62047. toEulerAngles(order?: string): Vector3;
  62048. /**
  62049. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62050. * @param result defines the vector which will be filled with the Euler angles
  62051. * @param order is a reserved parameter and is ignore for now
  62052. * @returns the current unchanged quaternion
  62053. */
  62054. toEulerAnglesToRef(result: Vector3): Quaternion;
  62055. /**
  62056. * Updates the given rotation matrix with the current quaternion values
  62057. * @param result defines the target matrix
  62058. * @returns the current unchanged quaternion
  62059. */
  62060. toRotationMatrix(result: Matrix): Quaternion;
  62061. /**
  62062. * Updates the current quaternion from the given rotation matrix values
  62063. * @param matrix defines the source matrix
  62064. * @returns the current updated quaternion
  62065. */
  62066. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62067. /**
  62068. * Creates a new quaternion from a rotation matrix
  62069. * @param matrix defines the source matrix
  62070. * @returns a new quaternion created from the given rotation matrix values
  62071. */
  62072. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62073. /**
  62074. * Updates the given quaternion with the given rotation matrix values
  62075. * @param matrix defines the source matrix
  62076. * @param result defines the target quaternion
  62077. */
  62078. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62079. /**
  62080. * Returns the dot product (float) between the quaternions "left" and "right"
  62081. * @param left defines the left operand
  62082. * @param right defines the right operand
  62083. * @returns the dot product
  62084. */
  62085. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62086. /**
  62087. * Checks if the two quaternions are close to each other
  62088. * @param quat0 defines the first quaternion to check
  62089. * @param quat1 defines the second quaternion to check
  62090. * @returns true if the two quaternions are close to each other
  62091. */
  62092. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62093. /**
  62094. * Creates an empty quaternion
  62095. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62096. */
  62097. static Zero(): Quaternion;
  62098. /**
  62099. * Inverse a given quaternion
  62100. * @param q defines the source quaternion
  62101. * @returns a new quaternion as the inverted current quaternion
  62102. */
  62103. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62104. /**
  62105. * Inverse a given quaternion
  62106. * @param q defines the source quaternion
  62107. * @param result the quaternion the result will be stored in
  62108. * @returns the result quaternion
  62109. */
  62110. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62111. /**
  62112. * Creates an identity quaternion
  62113. * @returns the identity quaternion
  62114. */
  62115. static Identity(): Quaternion;
  62116. /**
  62117. * Gets a boolean indicating if the given quaternion is identity
  62118. * @param quaternion defines the quaternion to check
  62119. * @returns true if the quaternion is identity
  62120. */
  62121. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62122. /**
  62123. * Creates a quaternion from a rotation around an axis
  62124. * @param axis defines the axis to use
  62125. * @param angle defines the angle to use
  62126. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62127. */
  62128. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62129. /**
  62130. * Creates a rotation around an axis and stores it into the given quaternion
  62131. * @param axis defines the axis to use
  62132. * @param angle defines the angle to use
  62133. * @param result defines the target quaternion
  62134. * @returns the target quaternion
  62135. */
  62136. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62137. /**
  62138. * Creates a new quaternion from data stored into an array
  62139. * @param array defines the data source
  62140. * @param offset defines the offset in the source array where the data starts
  62141. * @returns a new quaternion
  62142. */
  62143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62144. /**
  62145. * Create a quaternion from Euler rotation angles
  62146. * @param x Pitch
  62147. * @param y Yaw
  62148. * @param z Roll
  62149. * @returns the new Quaternion
  62150. */
  62151. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62152. /**
  62153. * Updates a quaternion from Euler rotation angles
  62154. * @param x Pitch
  62155. * @param y Yaw
  62156. * @param z Roll
  62157. * @param result the quaternion to store the result
  62158. * @returns the updated quaternion
  62159. */
  62160. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62161. /**
  62162. * Create a quaternion from Euler rotation vector
  62163. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62164. * @returns the new Quaternion
  62165. */
  62166. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62167. /**
  62168. * Updates a quaternion from Euler rotation vector
  62169. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62170. * @param result the quaternion to store the result
  62171. * @returns the updated quaternion
  62172. */
  62173. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62174. /**
  62175. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62176. * @param yaw defines the rotation around Y axis
  62177. * @param pitch defines the rotation around X axis
  62178. * @param roll defines the rotation around Z axis
  62179. * @returns the new quaternion
  62180. */
  62181. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62182. /**
  62183. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62184. * @param yaw defines the rotation around Y axis
  62185. * @param pitch defines the rotation around X axis
  62186. * @param roll defines the rotation around Z axis
  62187. * @param result defines the target quaternion
  62188. */
  62189. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62190. /**
  62191. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62192. * @param alpha defines the rotation around first axis
  62193. * @param beta defines the rotation around second axis
  62194. * @param gamma defines the rotation around third axis
  62195. * @returns the new quaternion
  62196. */
  62197. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62198. /**
  62199. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62200. * @param alpha defines the rotation around first axis
  62201. * @param beta defines the rotation around second axis
  62202. * @param gamma defines the rotation around third axis
  62203. * @param result defines the target quaternion
  62204. */
  62205. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62206. /**
  62207. * 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)
  62208. * @param axis1 defines the first axis
  62209. * @param axis2 defines the second axis
  62210. * @param axis3 defines the third axis
  62211. * @returns the new quaternion
  62212. */
  62213. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62214. /**
  62215. * 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
  62216. * @param axis1 defines the first axis
  62217. * @param axis2 defines the second axis
  62218. * @param axis3 defines the third axis
  62219. * @param ref defines the target quaternion
  62220. */
  62221. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62222. /**
  62223. * Interpolates between two quaternions
  62224. * @param left defines first quaternion
  62225. * @param right defines second quaternion
  62226. * @param amount defines the gradient to use
  62227. * @returns the new interpolated quaternion
  62228. */
  62229. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62230. /**
  62231. * Interpolates between two quaternions and stores it into a target quaternion
  62232. * @param left defines first quaternion
  62233. * @param right defines second quaternion
  62234. * @param amount defines the gradient to use
  62235. * @param result defines the target quaternion
  62236. */
  62237. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62238. /**
  62239. * Interpolate between two quaternions using Hermite interpolation
  62240. * @param value1 defines first quaternion
  62241. * @param tangent1 defines the incoming tangent
  62242. * @param value2 defines second quaternion
  62243. * @param tangent2 defines the outgoing tangent
  62244. * @param amount defines the target quaternion
  62245. * @returns the new interpolated quaternion
  62246. */
  62247. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62248. }
  62249. /**
  62250. * Class used to store matrix data (4x4)
  62251. */
  62252. export class Matrix {
  62253. private static _updateFlagSeed;
  62254. private static _identityReadOnly;
  62255. private _isIdentity;
  62256. private _isIdentityDirty;
  62257. private _isIdentity3x2;
  62258. private _isIdentity3x2Dirty;
  62259. /**
  62260. * Gets the update flag of the matrix which is an unique number for the matrix.
  62261. * It will be incremented every time the matrix data change.
  62262. * You can use it to speed the comparison between two versions of the same matrix.
  62263. */
  62264. updateFlag: number;
  62265. private readonly _m;
  62266. /**
  62267. * Gets the internal data of the matrix
  62268. */
  62269. readonly m: DeepImmutable<Float32Array>;
  62270. /** @hidden */
  62271. _markAsUpdated(): void;
  62272. /** @hidden */
  62273. private _updateIdentityStatus;
  62274. /**
  62275. * Creates an empty matrix (filled with zeros)
  62276. */
  62277. constructor();
  62278. /**
  62279. * Check if the current matrix is identity
  62280. * @returns true is the matrix is the identity matrix
  62281. */
  62282. isIdentity(): boolean;
  62283. /**
  62284. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62285. * @returns true is the matrix is the identity matrix
  62286. */
  62287. isIdentityAs3x2(): boolean;
  62288. /**
  62289. * Gets the determinant of the matrix
  62290. * @returns the matrix determinant
  62291. */
  62292. determinant(): number;
  62293. /**
  62294. * Returns the matrix as a Float32Array
  62295. * @returns the matrix underlying array
  62296. */
  62297. toArray(): DeepImmutable<Float32Array>;
  62298. /**
  62299. * Returns the matrix as a Float32Array
  62300. * @returns the matrix underlying array.
  62301. */
  62302. asArray(): DeepImmutable<Float32Array>;
  62303. /**
  62304. * Inverts the current matrix in place
  62305. * @returns the current inverted matrix
  62306. */
  62307. invert(): Matrix;
  62308. /**
  62309. * Sets all the matrix elements to zero
  62310. * @returns the current matrix
  62311. */
  62312. reset(): Matrix;
  62313. /**
  62314. * Adds the current matrix with a second one
  62315. * @param other defines the matrix to add
  62316. * @returns a new matrix as the addition of the current matrix and the given one
  62317. */
  62318. add(other: DeepImmutable<Matrix>): Matrix;
  62319. /**
  62320. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62321. * @param other defines the matrix to add
  62322. * @param result defines the target matrix
  62323. * @returns the current matrix
  62324. */
  62325. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62326. /**
  62327. * Adds in place the given matrix to the current matrix
  62328. * @param other defines the second operand
  62329. * @returns the current updated matrix
  62330. */
  62331. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62332. /**
  62333. * Sets the given matrix to the current inverted Matrix
  62334. * @param other defines the target matrix
  62335. * @returns the unmodified current matrix
  62336. */
  62337. invertToRef(other: Matrix): Matrix;
  62338. /**
  62339. * add a value at the specified position in the current Matrix
  62340. * @param index the index of the value within the matrix. between 0 and 15.
  62341. * @param value the value to be added
  62342. * @returns the current updated matrix
  62343. */
  62344. addAtIndex(index: number, value: number): Matrix;
  62345. /**
  62346. * mutiply the specified position in the current Matrix by a value
  62347. * @param index the index of the value within the matrix. between 0 and 15.
  62348. * @param value the value to be added
  62349. * @returns the current updated matrix
  62350. */
  62351. multiplyAtIndex(index: number, value: number): Matrix;
  62352. /**
  62353. * Inserts the translation vector (using 3 floats) in the current matrix
  62354. * @param x defines the 1st component of the translation
  62355. * @param y defines the 2nd component of the translation
  62356. * @param z defines the 3rd component of the translation
  62357. * @returns the current updated matrix
  62358. */
  62359. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62360. /**
  62361. * Adds the translation vector (using 3 floats) in the current matrix
  62362. * @param x defines the 1st component of the translation
  62363. * @param y defines the 2nd component of the translation
  62364. * @param z defines the 3rd component of the translation
  62365. * @returns the current updated matrix
  62366. */
  62367. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62368. /**
  62369. * Inserts the translation vector in the current matrix
  62370. * @param vector3 defines the translation to insert
  62371. * @returns the current updated matrix
  62372. */
  62373. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62374. /**
  62375. * Gets the translation value of the current matrix
  62376. * @returns a new Vector3 as the extracted translation from the matrix
  62377. */
  62378. getTranslation(): Vector3;
  62379. /**
  62380. * Fill a Vector3 with the extracted translation from the matrix
  62381. * @param result defines the Vector3 where to store the translation
  62382. * @returns the current matrix
  62383. */
  62384. getTranslationToRef(result: Vector3): Matrix;
  62385. /**
  62386. * Remove rotation and scaling part from the matrix
  62387. * @returns the updated matrix
  62388. */
  62389. removeRotationAndScaling(): Matrix;
  62390. /**
  62391. * Multiply two matrices
  62392. * @param other defines the second operand
  62393. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62394. */
  62395. multiply(other: DeepImmutable<Matrix>): Matrix;
  62396. /**
  62397. * Copy the current matrix from the given one
  62398. * @param other defines the source matrix
  62399. * @returns the current updated matrix
  62400. */
  62401. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62402. /**
  62403. * Populates the given array from the starting index with the current matrix values
  62404. * @param array defines the target array
  62405. * @param offset defines the offset in the target array where to start storing values
  62406. * @returns the current matrix
  62407. */
  62408. copyToArray(array: Float32Array, offset?: number): Matrix;
  62409. /**
  62410. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62411. * @param other defines the second operand
  62412. * @param result defines the matrix where to store the multiplication
  62413. * @returns the current matrix
  62414. */
  62415. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62416. /**
  62417. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62418. * @param other defines the second operand
  62419. * @param result defines the array where to store the multiplication
  62420. * @param offset defines the offset in the target array where to start storing values
  62421. * @returns the current matrix
  62422. */
  62423. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62424. /**
  62425. * Check equality between this matrix and a second one
  62426. * @param value defines the second matrix to compare
  62427. * @returns true is the current matrix and the given one values are strictly equal
  62428. */
  62429. equals(value: DeepImmutable<Matrix>): boolean;
  62430. /**
  62431. * Clone the current matrix
  62432. * @returns a new matrix from the current matrix
  62433. */
  62434. clone(): Matrix;
  62435. /**
  62436. * Returns the name of the current matrix class
  62437. * @returns the string "Matrix"
  62438. */
  62439. getClassName(): string;
  62440. /**
  62441. * Gets the hash code of the current matrix
  62442. * @returns the hash code
  62443. */
  62444. getHashCode(): number;
  62445. /**
  62446. * Decomposes the current Matrix into a translation, rotation and scaling components
  62447. * @param scale defines the scale vector3 given as a reference to update
  62448. * @param rotation defines the rotation quaternion given as a reference to update
  62449. * @param translation defines the translation vector3 given as a reference to update
  62450. * @returns true if operation was successful
  62451. */
  62452. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62453. /**
  62454. * Gets specific row of the matrix
  62455. * @param index defines the number of the row to get
  62456. * @returns the index-th row of the current matrix as a new Vector4
  62457. */
  62458. getRow(index: number): Nullable<Vector4>;
  62459. /**
  62460. * Sets the index-th row of the current matrix to the vector4 values
  62461. * @param index defines the number of the row to set
  62462. * @param row defines the target vector4
  62463. * @returns the updated current matrix
  62464. */
  62465. setRow(index: number, row: Vector4): Matrix;
  62466. /**
  62467. * Compute the transpose of the matrix
  62468. * @returns the new transposed matrix
  62469. */
  62470. transpose(): Matrix;
  62471. /**
  62472. * Compute the transpose of the matrix and store it in a given matrix
  62473. * @param result defines the target matrix
  62474. * @returns the current matrix
  62475. */
  62476. transposeToRef(result: Matrix): Matrix;
  62477. /**
  62478. * Sets the index-th row of the current matrix with the given 4 x float values
  62479. * @param index defines the row index
  62480. * @param x defines the x component to set
  62481. * @param y defines the y component to set
  62482. * @param z defines the z component to set
  62483. * @param w defines the w component to set
  62484. * @returns the updated current matrix
  62485. */
  62486. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62487. /**
  62488. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62489. * @param scale defines the scale factor
  62490. * @returns a new matrix
  62491. */
  62492. scale(scale: number): Matrix;
  62493. /**
  62494. * Scale the current matrix values by a factor to a given result matrix
  62495. * @param scale defines the scale factor
  62496. * @param result defines the matrix to store the result
  62497. * @returns the current matrix
  62498. */
  62499. scaleToRef(scale: number, result: Matrix): Matrix;
  62500. /**
  62501. * Scale the current matrix values by a factor and add the result to a given matrix
  62502. * @param scale defines the scale factor
  62503. * @param result defines the Matrix to store the result
  62504. * @returns the current matrix
  62505. */
  62506. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62507. /**
  62508. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62509. * @param ref matrix to store the result
  62510. */
  62511. toNormalMatrix(ref: Matrix): void;
  62512. /**
  62513. * Gets only rotation part of the current matrix
  62514. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62515. */
  62516. getRotationMatrix(): Matrix;
  62517. /**
  62518. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62519. * @param result defines the target matrix to store data to
  62520. * @returns the current matrix
  62521. */
  62522. getRotationMatrixToRef(result: Matrix): Matrix;
  62523. /**
  62524. * Toggles model matrix from being right handed to left handed in place and vice versa
  62525. */
  62526. toggleModelMatrixHandInPlace(): void;
  62527. /**
  62528. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62529. */
  62530. toggleProjectionMatrixHandInPlace(): void;
  62531. /**
  62532. * Creates a matrix from an array
  62533. * @param array defines the source array
  62534. * @param offset defines an offset in the source array
  62535. * @returns a new Matrix set from the starting index of the given array
  62536. */
  62537. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62538. /**
  62539. * Copy the content of an array into a given matrix
  62540. * @param array defines the source array
  62541. * @param offset defines an offset in the source array
  62542. * @param result defines the target matrix
  62543. */
  62544. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62545. /**
  62546. * Stores an array into a matrix after having multiplied each component by a given factor
  62547. * @param array defines the source array
  62548. * @param offset defines the offset in the source array
  62549. * @param scale defines the scaling factor
  62550. * @param result defines the target matrix
  62551. */
  62552. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62553. /**
  62554. * Gets an identity matrix that must not be updated
  62555. */
  62556. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62557. /**
  62558. * Stores a list of values (16) inside a given matrix
  62559. * @param initialM11 defines 1st value of 1st row
  62560. * @param initialM12 defines 2nd value of 1st row
  62561. * @param initialM13 defines 3rd value of 1st row
  62562. * @param initialM14 defines 4th value of 1st row
  62563. * @param initialM21 defines 1st value of 2nd row
  62564. * @param initialM22 defines 2nd value of 2nd row
  62565. * @param initialM23 defines 3rd value of 2nd row
  62566. * @param initialM24 defines 4th value of 2nd row
  62567. * @param initialM31 defines 1st value of 3rd row
  62568. * @param initialM32 defines 2nd value of 3rd row
  62569. * @param initialM33 defines 3rd value of 3rd row
  62570. * @param initialM34 defines 4th value of 3rd row
  62571. * @param initialM41 defines 1st value of 4th row
  62572. * @param initialM42 defines 2nd value of 4th row
  62573. * @param initialM43 defines 3rd value of 4th row
  62574. * @param initialM44 defines 4th value of 4th row
  62575. * @param result defines the target matrix
  62576. */
  62577. 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;
  62578. /**
  62579. * Creates new matrix from a list of values (16)
  62580. * @param initialM11 defines 1st value of 1st row
  62581. * @param initialM12 defines 2nd value of 1st row
  62582. * @param initialM13 defines 3rd value of 1st row
  62583. * @param initialM14 defines 4th value of 1st row
  62584. * @param initialM21 defines 1st value of 2nd row
  62585. * @param initialM22 defines 2nd value of 2nd row
  62586. * @param initialM23 defines 3rd value of 2nd row
  62587. * @param initialM24 defines 4th value of 2nd row
  62588. * @param initialM31 defines 1st value of 3rd row
  62589. * @param initialM32 defines 2nd value of 3rd row
  62590. * @param initialM33 defines 3rd value of 3rd row
  62591. * @param initialM34 defines 4th value of 3rd row
  62592. * @param initialM41 defines 1st value of 4th row
  62593. * @param initialM42 defines 2nd value of 4th row
  62594. * @param initialM43 defines 3rd value of 4th row
  62595. * @param initialM44 defines 4th value of 4th row
  62596. * @returns the new matrix
  62597. */
  62598. 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;
  62599. /**
  62600. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62601. * @param scale defines the scale vector3
  62602. * @param rotation defines the rotation quaternion
  62603. * @param translation defines the translation vector3
  62604. * @returns a new matrix
  62605. */
  62606. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62607. /**
  62608. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62609. * @param scale defines the scale vector3
  62610. * @param rotation defines the rotation quaternion
  62611. * @param translation defines the translation vector3
  62612. * @param result defines the target matrix
  62613. */
  62614. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62615. /**
  62616. * Creates a new identity matrix
  62617. * @returns a new identity matrix
  62618. */
  62619. static Identity(): Matrix;
  62620. /**
  62621. * Creates a new identity matrix and stores the result in a given matrix
  62622. * @param result defines the target matrix
  62623. */
  62624. static IdentityToRef(result: Matrix): void;
  62625. /**
  62626. * Creates a new zero matrix
  62627. * @returns a new zero matrix
  62628. */
  62629. static Zero(): Matrix;
  62630. /**
  62631. * Creates a new rotation matrix for "angle" radians around the X axis
  62632. * @param angle defines the angle (in radians) to use
  62633. * @return the new matrix
  62634. */
  62635. static RotationX(angle: number): Matrix;
  62636. /**
  62637. * Creates a new matrix as the invert of a given matrix
  62638. * @param source defines the source matrix
  62639. * @returns the new matrix
  62640. */
  62641. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62642. /**
  62643. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62644. * @param angle defines the angle (in radians) to use
  62645. * @param result defines the target matrix
  62646. */
  62647. static RotationXToRef(angle: number, result: Matrix): void;
  62648. /**
  62649. * Creates a new rotation matrix for "angle" radians around the Y axis
  62650. * @param angle defines the angle (in radians) to use
  62651. * @return the new matrix
  62652. */
  62653. static RotationY(angle: number): Matrix;
  62654. /**
  62655. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62656. * @param angle defines the angle (in radians) to use
  62657. * @param result defines the target matrix
  62658. */
  62659. static RotationYToRef(angle: number, result: Matrix): void;
  62660. /**
  62661. * Creates a new rotation matrix for "angle" radians around the Z axis
  62662. * @param angle defines the angle (in radians) to use
  62663. * @return the new matrix
  62664. */
  62665. static RotationZ(angle: number): Matrix;
  62666. /**
  62667. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62668. * @param angle defines the angle (in radians) to use
  62669. * @param result defines the target matrix
  62670. */
  62671. static RotationZToRef(angle: number, result: Matrix): void;
  62672. /**
  62673. * Creates a new rotation matrix for "angle" radians around the given axis
  62674. * @param axis defines the axis to use
  62675. * @param angle defines the angle (in radians) to use
  62676. * @return the new matrix
  62677. */
  62678. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62679. /**
  62680. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62681. * @param axis defines the axis to use
  62682. * @param angle defines the angle (in radians) to use
  62683. * @param result defines the target matrix
  62684. */
  62685. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62686. /**
  62687. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62688. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62689. * @param from defines the vector to align
  62690. * @param to defines the vector to align to
  62691. * @param result defines the target matrix
  62692. */
  62693. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62694. /**
  62695. * Creates a rotation matrix
  62696. * @param yaw defines the yaw angle in radians (Y axis)
  62697. * @param pitch defines the pitch angle in radians (X axis)
  62698. * @param roll defines the roll angle in radians (X axis)
  62699. * @returns the new rotation matrix
  62700. */
  62701. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62702. /**
  62703. * Creates a rotation matrix and stores it in a given matrix
  62704. * @param yaw defines the yaw angle in radians (Y axis)
  62705. * @param pitch defines the pitch angle in radians (X axis)
  62706. * @param roll defines the roll angle in radians (X axis)
  62707. * @param result defines the target matrix
  62708. */
  62709. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62710. /**
  62711. * Creates a scaling matrix
  62712. * @param x defines the scale factor on X axis
  62713. * @param y defines the scale factor on Y axis
  62714. * @param z defines the scale factor on Z axis
  62715. * @returns the new matrix
  62716. */
  62717. static Scaling(x: number, y: number, z: number): Matrix;
  62718. /**
  62719. * Creates a scaling matrix and stores it in a given matrix
  62720. * @param x defines the scale factor on X axis
  62721. * @param y defines the scale factor on Y axis
  62722. * @param z defines the scale factor on Z axis
  62723. * @param result defines the target matrix
  62724. */
  62725. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62726. /**
  62727. * Creates a translation matrix
  62728. * @param x defines the translation on X axis
  62729. * @param y defines the translation on Y axis
  62730. * @param z defines the translationon Z axis
  62731. * @returns the new matrix
  62732. */
  62733. static Translation(x: number, y: number, z: number): Matrix;
  62734. /**
  62735. * Creates a translation matrix and stores it in a given matrix
  62736. * @param x defines the translation on X axis
  62737. * @param y defines the translation on Y axis
  62738. * @param z defines the translationon Z axis
  62739. * @param result defines the target matrix
  62740. */
  62741. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62742. /**
  62743. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62744. * @param startValue defines the start value
  62745. * @param endValue defines the end value
  62746. * @param gradient defines the gradient factor
  62747. * @returns the new matrix
  62748. */
  62749. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62750. /**
  62751. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62752. * @param startValue defines the start value
  62753. * @param endValue defines the end value
  62754. * @param gradient defines the gradient factor
  62755. * @param result defines the Matrix object where to store data
  62756. */
  62757. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62758. /**
  62759. * Builds a new matrix whose values are computed by:
  62760. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62761. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62762. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62763. * @param startValue defines the first matrix
  62764. * @param endValue defines the second matrix
  62765. * @param gradient defines the gradient between the two matrices
  62766. * @returns the new matrix
  62767. */
  62768. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62769. /**
  62770. * Update a matrix to values which are computed by:
  62771. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62772. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62773. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62774. * @param startValue defines the first matrix
  62775. * @param endValue defines the second matrix
  62776. * @param gradient defines the gradient between the two matrices
  62777. * @param result defines the target matrix
  62778. */
  62779. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62780. /**
  62781. * 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"
  62782. * This function works in left handed mode
  62783. * @param eye defines the final position of the entity
  62784. * @param target defines where the entity should look at
  62785. * @param up defines the up vector for the entity
  62786. * @returns the new matrix
  62787. */
  62788. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62789. /**
  62790. * 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".
  62791. * This function works in left handed mode
  62792. * @param eye defines the final position of the entity
  62793. * @param target defines where the entity should look at
  62794. * @param up defines the up vector for the entity
  62795. * @param result defines the target matrix
  62796. */
  62797. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62798. /**
  62799. * 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"
  62800. * This function works in right handed mode
  62801. * @param eye defines the final position of the entity
  62802. * @param target defines where the entity should look at
  62803. * @param up defines the up vector for the entity
  62804. * @returns the new matrix
  62805. */
  62806. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62807. /**
  62808. * 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".
  62809. * This function works in right handed mode
  62810. * @param eye defines the final position of the entity
  62811. * @param target defines where the entity should look at
  62812. * @param up defines the up vector for the entity
  62813. * @param result defines the target matrix
  62814. */
  62815. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62816. /**
  62817. * Create a left-handed orthographic projection matrix
  62818. * @param width defines the viewport width
  62819. * @param height defines the viewport height
  62820. * @param znear defines the near clip plane
  62821. * @param zfar defines the far clip plane
  62822. * @returns a new matrix as a left-handed orthographic projection matrix
  62823. */
  62824. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62825. /**
  62826. * Store a left-handed orthographic projection to a given matrix
  62827. * @param width defines the viewport width
  62828. * @param height defines the viewport height
  62829. * @param znear defines the near clip plane
  62830. * @param zfar defines the far clip plane
  62831. * @param result defines the target matrix
  62832. */
  62833. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62834. /**
  62835. * Create a left-handed orthographic projection matrix
  62836. * @param left defines the viewport left coordinate
  62837. * @param right defines the viewport right coordinate
  62838. * @param bottom defines the viewport bottom coordinate
  62839. * @param top defines the viewport top coordinate
  62840. * @param znear defines the near clip plane
  62841. * @param zfar defines the far clip plane
  62842. * @returns a new matrix as a left-handed orthographic projection matrix
  62843. */
  62844. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62845. /**
  62846. * Stores a left-handed orthographic projection into a given matrix
  62847. * @param left defines the viewport left coordinate
  62848. * @param right defines the viewport right coordinate
  62849. * @param bottom defines the viewport bottom coordinate
  62850. * @param top defines the viewport top coordinate
  62851. * @param znear defines the near clip plane
  62852. * @param zfar defines the far clip plane
  62853. * @param result defines the target matrix
  62854. */
  62855. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62856. /**
  62857. * Creates a right-handed orthographic projection matrix
  62858. * @param left defines the viewport left coordinate
  62859. * @param right defines the viewport right coordinate
  62860. * @param bottom defines the viewport bottom coordinate
  62861. * @param top defines the viewport top coordinate
  62862. * @param znear defines the near clip plane
  62863. * @param zfar defines the far clip plane
  62864. * @returns a new matrix as a right-handed orthographic projection matrix
  62865. */
  62866. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62867. /**
  62868. * Stores a right-handed orthographic projection into a given matrix
  62869. * @param left defines the viewport left coordinate
  62870. * @param right defines the viewport right coordinate
  62871. * @param bottom defines the viewport bottom coordinate
  62872. * @param top defines the viewport top coordinate
  62873. * @param znear defines the near clip plane
  62874. * @param zfar defines the far clip plane
  62875. * @param result defines the target matrix
  62876. */
  62877. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62878. /**
  62879. * Creates a left-handed perspective projection matrix
  62880. * @param width defines the viewport width
  62881. * @param height defines the viewport height
  62882. * @param znear defines the near clip plane
  62883. * @param zfar defines the far clip plane
  62884. * @returns a new matrix as a left-handed perspective projection matrix
  62885. */
  62886. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62887. /**
  62888. * Creates a left-handed perspective projection matrix
  62889. * @param fov defines the horizontal field of view
  62890. * @param aspect defines the aspect ratio
  62891. * @param znear defines the near clip plane
  62892. * @param zfar defines the far clip plane
  62893. * @returns a new matrix as a left-handed perspective projection matrix
  62894. */
  62895. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62896. /**
  62897. * Stores a left-handed perspective projection into a given matrix
  62898. * @param fov defines the horizontal field of view
  62899. * @param aspect defines the aspect ratio
  62900. * @param znear defines the near clip plane
  62901. * @param zfar defines the far clip plane
  62902. * @param result defines the target matrix
  62903. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62904. */
  62905. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62906. /**
  62907. * Creates a right-handed perspective projection matrix
  62908. * @param fov defines the horizontal field of view
  62909. * @param aspect defines the aspect ratio
  62910. * @param znear defines the near clip plane
  62911. * @param zfar defines the far clip plane
  62912. * @returns a new matrix as a right-handed perspective projection matrix
  62913. */
  62914. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  62915. /**
  62916. * Stores a right-handed perspective projection into a given matrix
  62917. * @param fov defines the horizontal field of view
  62918. * @param aspect defines the aspect ratio
  62919. * @param znear defines the near clip plane
  62920. * @param zfar defines the far clip plane
  62921. * @param result defines the target matrix
  62922. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  62923. */
  62924. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  62925. /**
  62926. * Stores a perspective projection for WebVR info a given matrix
  62927. * @param fov defines the field of view
  62928. * @param znear defines the near clip plane
  62929. * @param zfar defines the far clip plane
  62930. * @param result defines the target matrix
  62931. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  62932. */
  62933. static PerspectiveFovWebVRToRef(fov: {
  62934. upDegrees: number;
  62935. downDegrees: number;
  62936. leftDegrees: number;
  62937. rightDegrees: number;
  62938. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  62939. /**
  62940. * Computes a complete transformation matrix
  62941. * @param viewport defines the viewport to use
  62942. * @param world defines the world matrix
  62943. * @param view defines the view matrix
  62944. * @param projection defines the projection matrix
  62945. * @param zmin defines the near clip plane
  62946. * @param zmax defines the far clip plane
  62947. * @returns the transformation matrix
  62948. */
  62949. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  62950. /**
  62951. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  62952. * @param matrix defines the matrix to use
  62953. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  62954. */
  62955. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  62956. /**
  62957. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  62958. * @param matrix defines the matrix to use
  62959. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  62960. */
  62961. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  62962. /**
  62963. * Compute the transpose of a given matrix
  62964. * @param matrix defines the matrix to transpose
  62965. * @returns the new matrix
  62966. */
  62967. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  62968. /**
  62969. * Compute the transpose of a matrix and store it in a target matrix
  62970. * @param matrix defines the matrix to transpose
  62971. * @param result defines the target matrix
  62972. */
  62973. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  62974. /**
  62975. * Computes a reflection matrix from a plane
  62976. * @param plane defines the reflection plane
  62977. * @returns a new matrix
  62978. */
  62979. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  62980. /**
  62981. * Computes a reflection matrix from a plane
  62982. * @param plane defines the reflection plane
  62983. * @param result defines the target matrix
  62984. */
  62985. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  62986. /**
  62987. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  62988. * @param xaxis defines the value of the 1st axis
  62989. * @param yaxis defines the value of the 2nd axis
  62990. * @param zaxis defines the value of the 3rd axis
  62991. * @param result defines the target matrix
  62992. */
  62993. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  62994. /**
  62995. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  62996. * @param quat defines the quaternion to use
  62997. * @param result defines the target matrix
  62998. */
  62999. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63000. }
  63001. /**
  63002. * Represens a plane by the equation ax + by + cz + d = 0
  63003. */
  63004. export class Plane {
  63005. /**
  63006. * Normal of the plane (a,b,c)
  63007. */
  63008. normal: Vector3;
  63009. /**
  63010. * d component of the plane
  63011. */
  63012. d: number;
  63013. /**
  63014. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63015. * @param a a component of the plane
  63016. * @param b b component of the plane
  63017. * @param c c component of the plane
  63018. * @param d d component of the plane
  63019. */
  63020. constructor(a: number, b: number, c: number, d: number);
  63021. /**
  63022. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63023. */
  63024. asArray(): number[];
  63025. /**
  63026. * @returns a new plane copied from the current Plane.
  63027. */
  63028. clone(): Plane;
  63029. /**
  63030. * @returns the string "Plane".
  63031. */
  63032. getClassName(): string;
  63033. /**
  63034. * @returns the Plane hash code.
  63035. */
  63036. getHashCode(): number;
  63037. /**
  63038. * Normalize the current Plane in place.
  63039. * @returns the updated Plane.
  63040. */
  63041. normalize(): Plane;
  63042. /**
  63043. * Applies a transformation the plane and returns the result
  63044. * @param transformation the transformation matrix to be applied to the plane
  63045. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63046. */
  63047. transform(transformation: DeepImmutable<Matrix>): Plane;
  63048. /**
  63049. * Calcualtte the dot product between the point and the plane normal
  63050. * @param point point to calculate the dot product with
  63051. * @returns the dot product (float) of the point coordinates and the plane normal.
  63052. */
  63053. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63054. /**
  63055. * Updates the current Plane from the plane defined by the three given points.
  63056. * @param point1 one of the points used to contruct the plane
  63057. * @param point2 one of the points used to contruct the plane
  63058. * @param point3 one of the points used to contruct the plane
  63059. * @returns the updated Plane.
  63060. */
  63061. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63062. /**
  63063. * Checks if the plane is facing a given direction
  63064. * @param direction the direction to check if the plane is facing
  63065. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63066. * @returns True is the vector "direction" is the same side than the plane normal.
  63067. */
  63068. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63069. /**
  63070. * Calculates the distance to a point
  63071. * @param point point to calculate distance to
  63072. * @returns the signed distance (float) from the given point to the Plane.
  63073. */
  63074. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63075. /**
  63076. * Creates a plane from an array
  63077. * @param array the array to create a plane from
  63078. * @returns a new Plane from the given array.
  63079. */
  63080. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63081. /**
  63082. * Creates a plane from three points
  63083. * @param point1 point used to create the plane
  63084. * @param point2 point used to create the plane
  63085. * @param point3 point used to create the plane
  63086. * @returns a new Plane defined by the three given points.
  63087. */
  63088. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63089. /**
  63090. * Creates a plane from an origin point and a normal
  63091. * @param origin origin of the plane to be constructed
  63092. * @param normal normal of the plane to be constructed
  63093. * @returns a new Plane the normal vector to this plane at the given origin point.
  63094. * Note : the vector "normal" is updated because normalized.
  63095. */
  63096. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63097. /**
  63098. * Calculates the distance from a plane and a point
  63099. * @param origin origin of the plane to be constructed
  63100. * @param normal normal of the plane to be constructed
  63101. * @param point point to calculate distance to
  63102. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63103. */
  63104. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63105. }
  63106. /**
  63107. * Class used to represent a viewport on screen
  63108. */
  63109. export class Viewport {
  63110. /** viewport left coordinate */
  63111. x: number;
  63112. /** viewport top coordinate */
  63113. y: number;
  63114. /**viewport width */
  63115. width: number;
  63116. /** viewport height */
  63117. height: number;
  63118. /**
  63119. * Creates a Viewport object located at (x, y) and sized (width, height)
  63120. * @param x defines viewport left coordinate
  63121. * @param y defines viewport top coordinate
  63122. * @param width defines the viewport width
  63123. * @param height defines the viewport height
  63124. */
  63125. constructor(
  63126. /** viewport left coordinate */
  63127. x: number,
  63128. /** viewport top coordinate */
  63129. y: number,
  63130. /**viewport width */
  63131. width: number,
  63132. /** viewport height */
  63133. height: number);
  63134. /**
  63135. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63136. * @param renderWidth defines the rendering width
  63137. * @param renderHeight defines the rendering height
  63138. * @returns a new Viewport
  63139. */
  63140. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63141. /**
  63142. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63143. * @param renderWidth defines the rendering width
  63144. * @param renderHeight defines the rendering height
  63145. * @param ref defines the target viewport
  63146. * @returns the current viewport
  63147. */
  63148. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63149. /**
  63150. * Returns a new Viewport copied from the current one
  63151. * @returns a new Viewport
  63152. */
  63153. clone(): Viewport;
  63154. }
  63155. /**
  63156. * Reprasents a camera frustum
  63157. */
  63158. export class Frustum {
  63159. /**
  63160. * Gets the planes representing the frustum
  63161. * @param transform matrix to be applied to the returned planes
  63162. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63163. */
  63164. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63165. /**
  63166. * Gets the near frustum plane transformed by the transform matrix
  63167. * @param transform transformation matrix to be applied to the resulting frustum plane
  63168. * @param frustumPlane the resuling frustum plane
  63169. */
  63170. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63171. /**
  63172. * Gets the far frustum plane transformed by the transform matrix
  63173. * @param transform transformation matrix to be applied to the resulting frustum plane
  63174. * @param frustumPlane the resuling frustum plane
  63175. */
  63176. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63177. /**
  63178. * Gets the left frustum plane transformed by the transform matrix
  63179. * @param transform transformation matrix to be applied to the resulting frustum plane
  63180. * @param frustumPlane the resuling frustum plane
  63181. */
  63182. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63183. /**
  63184. * Gets the right frustum plane transformed by the transform matrix
  63185. * @param transform transformation matrix to be applied to the resulting frustum plane
  63186. * @param frustumPlane the resuling frustum plane
  63187. */
  63188. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63189. /**
  63190. * Gets the top frustum plane transformed by the transform matrix
  63191. * @param transform transformation matrix to be applied to the resulting frustum plane
  63192. * @param frustumPlane the resuling frustum plane
  63193. */
  63194. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63195. /**
  63196. * Gets the bottom frustum plane transformed by the transform matrix
  63197. * @param transform transformation matrix to be applied to the resulting frustum plane
  63198. * @param frustumPlane the resuling frustum plane
  63199. */
  63200. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63201. /**
  63202. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63203. * @param transform transformation matrix to be applied to the resulting frustum planes
  63204. * @param frustumPlanes the resuling frustum planes
  63205. */
  63206. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63207. }
  63208. /** Defines supported spaces */
  63209. export enum Space {
  63210. /** Local (object) space */
  63211. LOCAL = 0,
  63212. /** World space */
  63213. WORLD = 1,
  63214. /** Bone space */
  63215. BONE = 2
  63216. }
  63217. /** Defines the 3 main axes */
  63218. export class Axis {
  63219. /** X axis */
  63220. static X: Vector3;
  63221. /** Y axis */
  63222. static Y: Vector3;
  63223. /** Z axis */
  63224. static Z: Vector3;
  63225. }
  63226. /** Class used to represent a Bezier curve */
  63227. export class BezierCurve {
  63228. /**
  63229. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63230. * @param t defines the time
  63231. * @param x1 defines the left coordinate on X axis
  63232. * @param y1 defines the left coordinate on Y axis
  63233. * @param x2 defines the right coordinate on X axis
  63234. * @param y2 defines the right coordinate on Y axis
  63235. * @returns the interpolated value
  63236. */
  63237. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63238. }
  63239. /**
  63240. * Defines potential orientation for back face culling
  63241. */
  63242. export enum Orientation {
  63243. /**
  63244. * Clockwise
  63245. */
  63246. CW = 0,
  63247. /** Counter clockwise */
  63248. CCW = 1
  63249. }
  63250. /**
  63251. * Defines angle representation
  63252. */
  63253. export class Angle {
  63254. private _radians;
  63255. /**
  63256. * Creates an Angle object of "radians" radians (float).
  63257. * @param radians the angle in radians
  63258. */
  63259. constructor(radians: number);
  63260. /**
  63261. * Get value in degrees
  63262. * @returns the Angle value in degrees (float)
  63263. */
  63264. degrees(): number;
  63265. /**
  63266. * Get value in radians
  63267. * @returns the Angle value in radians (float)
  63268. */
  63269. radians(): number;
  63270. /**
  63271. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63272. * @param a defines first vector
  63273. * @param b defines second vector
  63274. * @returns a new Angle
  63275. */
  63276. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63277. /**
  63278. * Gets a new Angle object from the given float in radians
  63279. * @param radians defines the angle value in radians
  63280. * @returns a new Angle
  63281. */
  63282. static FromRadians(radians: number): Angle;
  63283. /**
  63284. * Gets a new Angle object from the given float in degrees
  63285. * @param degrees defines the angle value in degrees
  63286. * @returns a new Angle
  63287. */
  63288. static FromDegrees(degrees: number): Angle;
  63289. }
  63290. /**
  63291. * This represents an arc in a 2d space.
  63292. */
  63293. export class Arc2 {
  63294. /** Defines the start point of the arc */
  63295. startPoint: Vector2;
  63296. /** Defines the mid point of the arc */
  63297. midPoint: Vector2;
  63298. /** Defines the end point of the arc */
  63299. endPoint: Vector2;
  63300. /**
  63301. * Defines the center point of the arc.
  63302. */
  63303. centerPoint: Vector2;
  63304. /**
  63305. * Defines the radius of the arc.
  63306. */
  63307. radius: number;
  63308. /**
  63309. * Defines the angle of the arc (from mid point to end point).
  63310. */
  63311. angle: Angle;
  63312. /**
  63313. * Defines the start angle of the arc (from start point to middle point).
  63314. */
  63315. startAngle: Angle;
  63316. /**
  63317. * Defines the orientation of the arc (clock wise/counter clock wise).
  63318. */
  63319. orientation: Orientation;
  63320. /**
  63321. * Creates an Arc object from the three given points : start, middle and end.
  63322. * @param startPoint Defines the start point of the arc
  63323. * @param midPoint Defines the midlle point of the arc
  63324. * @param endPoint Defines the end point of the arc
  63325. */
  63326. constructor(
  63327. /** Defines the start point of the arc */
  63328. startPoint: Vector2,
  63329. /** Defines the mid point of the arc */
  63330. midPoint: Vector2,
  63331. /** Defines the end point of the arc */
  63332. endPoint: Vector2);
  63333. }
  63334. /**
  63335. * Represents a 2D path made up of multiple 2D points
  63336. */
  63337. export class Path2 {
  63338. private _points;
  63339. private _length;
  63340. /**
  63341. * If the path start and end point are the same
  63342. */
  63343. closed: boolean;
  63344. /**
  63345. * Creates a Path2 object from the starting 2D coordinates x and y.
  63346. * @param x the starting points x value
  63347. * @param y the starting points y value
  63348. */
  63349. constructor(x: number, y: number);
  63350. /**
  63351. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63352. * @param x the added points x value
  63353. * @param y the added points y value
  63354. * @returns the updated Path2.
  63355. */
  63356. addLineTo(x: number, y: number): Path2;
  63357. /**
  63358. * 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.
  63359. * @param midX middle point x value
  63360. * @param midY middle point y value
  63361. * @param endX end point x value
  63362. * @param endY end point y value
  63363. * @param numberOfSegments (default: 36)
  63364. * @returns the updated Path2.
  63365. */
  63366. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63367. /**
  63368. * Closes the Path2.
  63369. * @returns the Path2.
  63370. */
  63371. close(): Path2;
  63372. /**
  63373. * Gets the sum of the distance between each sequential point in the path
  63374. * @returns the Path2 total length (float).
  63375. */
  63376. length(): number;
  63377. /**
  63378. * Gets the points which construct the path
  63379. * @returns the Path2 internal array of points.
  63380. */
  63381. getPoints(): Vector2[];
  63382. /**
  63383. * Retreives the point at the distance aways from the starting point
  63384. * @param normalizedLengthPosition the length along the path to retreive the point from
  63385. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63386. */
  63387. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63388. /**
  63389. * Creates a new path starting from an x and y position
  63390. * @param x starting x value
  63391. * @param y starting y value
  63392. * @returns a new Path2 starting at the coordinates (x, y).
  63393. */
  63394. static StartingAt(x: number, y: number): Path2;
  63395. }
  63396. /**
  63397. * Represents a 3D path made up of multiple 3D points
  63398. */
  63399. export class Path3D {
  63400. /**
  63401. * an array of Vector3, the curve axis of the Path3D
  63402. */
  63403. path: Vector3[];
  63404. private _curve;
  63405. private _distances;
  63406. private _tangents;
  63407. private _normals;
  63408. private _binormals;
  63409. private _raw;
  63410. /**
  63411. * new Path3D(path, normal, raw)
  63412. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63413. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63414. * @param path an array of Vector3, the curve axis of the Path3D
  63415. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63416. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63417. */
  63418. constructor(
  63419. /**
  63420. * an array of Vector3, the curve axis of the Path3D
  63421. */
  63422. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63423. /**
  63424. * Returns the Path3D array of successive Vector3 designing its curve.
  63425. * @returns the Path3D array of successive Vector3 designing its curve.
  63426. */
  63427. getCurve(): Vector3[];
  63428. /**
  63429. * Returns an array populated with tangent vectors on each Path3D curve point.
  63430. * @returns an array populated with tangent vectors on each Path3D curve point.
  63431. */
  63432. getTangents(): Vector3[];
  63433. /**
  63434. * Returns an array populated with normal vectors on each Path3D curve point.
  63435. * @returns an array populated with normal vectors on each Path3D curve point.
  63436. */
  63437. getNormals(): Vector3[];
  63438. /**
  63439. * Returns an array populated with binormal vectors on each Path3D curve point.
  63440. * @returns an array populated with binormal vectors on each Path3D curve point.
  63441. */
  63442. getBinormals(): Vector3[];
  63443. /**
  63444. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63445. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63446. */
  63447. getDistances(): number[];
  63448. /**
  63449. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63450. * @param path path which all values are copied into the curves points
  63451. * @param firstNormal which should be projected onto the curve
  63452. * @returns the same object updated.
  63453. */
  63454. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63455. private _compute;
  63456. private _getFirstNonNullVector;
  63457. private _getLastNonNullVector;
  63458. private _normalVector;
  63459. }
  63460. /**
  63461. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63462. * A Curve3 is designed from a series of successive Vector3.
  63463. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63464. */
  63465. export class Curve3 {
  63466. private _points;
  63467. private _length;
  63468. /**
  63469. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63470. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63471. * @param v1 (Vector3) the control point
  63472. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63473. * @param nbPoints (integer) the wanted number of points in the curve
  63474. * @returns the created Curve3
  63475. */
  63476. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63477. /**
  63478. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63479. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63480. * @param v1 (Vector3) the first control point
  63481. * @param v2 (Vector3) the second control point
  63482. * @param v3 (Vector3) the end point of the Cubic Bezier
  63483. * @param nbPoints (integer) the wanted number of points in the curve
  63484. * @returns the created Curve3
  63485. */
  63486. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63487. /**
  63488. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63489. * @param p1 (Vector3) the origin point of the Hermite Spline
  63490. * @param t1 (Vector3) the tangent vector at the origin point
  63491. * @param p2 (Vector3) the end point of the Hermite Spline
  63492. * @param t2 (Vector3) the tangent vector at the end point
  63493. * @param nbPoints (integer) the wanted number of points in the curve
  63494. * @returns the created Curve3
  63495. */
  63496. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63497. /**
  63498. * Returns a Curve3 object along a CatmullRom Spline curve :
  63499. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63500. * @param nbPoints (integer) the wanted number of points between each curve control points
  63501. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63502. * @returns the created Curve3
  63503. */
  63504. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63505. /**
  63506. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63507. * A Curve3 is designed from a series of successive Vector3.
  63508. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63509. * @param points points which make up the curve
  63510. */
  63511. constructor(points: Vector3[]);
  63512. /**
  63513. * @returns the Curve3 stored array of successive Vector3
  63514. */
  63515. getPoints(): Vector3[];
  63516. /**
  63517. * @returns the computed length (float) of the curve.
  63518. */
  63519. length(): number;
  63520. /**
  63521. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63522. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63523. * curveA and curveB keep unchanged.
  63524. * @param curve the curve to continue from this curve
  63525. * @returns the newly constructed curve
  63526. */
  63527. continue(curve: DeepImmutable<Curve3>): Curve3;
  63528. private _computeLength;
  63529. }
  63530. /**
  63531. * Contains position and normal vectors for a vertex
  63532. */
  63533. export class PositionNormalVertex {
  63534. /** the position of the vertex (defaut: 0,0,0) */
  63535. position: Vector3;
  63536. /** the normal of the vertex (defaut: 0,1,0) */
  63537. normal: Vector3;
  63538. /**
  63539. * Creates a PositionNormalVertex
  63540. * @param position the position of the vertex (defaut: 0,0,0)
  63541. * @param normal the normal of the vertex (defaut: 0,1,0)
  63542. */
  63543. constructor(
  63544. /** the position of the vertex (defaut: 0,0,0) */
  63545. position?: Vector3,
  63546. /** the normal of the vertex (defaut: 0,1,0) */
  63547. normal?: Vector3);
  63548. /**
  63549. * Clones the PositionNormalVertex
  63550. * @returns the cloned PositionNormalVertex
  63551. */
  63552. clone(): PositionNormalVertex;
  63553. }
  63554. /**
  63555. * Contains position, normal and uv vectors for a vertex
  63556. */
  63557. export class PositionNormalTextureVertex {
  63558. /** the position of the vertex (defaut: 0,0,0) */
  63559. position: Vector3;
  63560. /** the normal of the vertex (defaut: 0,1,0) */
  63561. normal: Vector3;
  63562. /** the uv of the vertex (default: 0,0) */
  63563. uv: Vector2;
  63564. /**
  63565. * Creates a PositionNormalTextureVertex
  63566. * @param position the position of the vertex (defaut: 0,0,0)
  63567. * @param normal the normal of the vertex (defaut: 0,1,0)
  63568. * @param uv the uv of the vertex (default: 0,0)
  63569. */
  63570. constructor(
  63571. /** the position of the vertex (defaut: 0,0,0) */
  63572. position?: Vector3,
  63573. /** the normal of the vertex (defaut: 0,1,0) */
  63574. normal?: Vector3,
  63575. /** the uv of the vertex (default: 0,0) */
  63576. uv?: Vector2);
  63577. /**
  63578. * Clones the PositionNormalTextureVertex
  63579. * @returns the cloned PositionNormalTextureVertex
  63580. */
  63581. clone(): PositionNormalTextureVertex;
  63582. }
  63583. /**
  63584. * @hidden
  63585. */
  63586. export class Tmp {
  63587. static Color3: Color3[];
  63588. static Color4: Color4[];
  63589. static Vector2: Vector2[];
  63590. static Vector3: Vector3[];
  63591. static Vector4: Vector4[];
  63592. static Quaternion: Quaternion[];
  63593. static Matrix: Matrix[];
  63594. }
  63595. }
  63596. declare module BABYLON {
  63597. /**
  63598. * Class used to enable access to offline support
  63599. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63600. */
  63601. export interface IOfflineProvider {
  63602. /**
  63603. * Gets a boolean indicating if scene must be saved in the database
  63604. */
  63605. enableSceneOffline: boolean;
  63606. /**
  63607. * Gets a boolean indicating if textures must be saved in the database
  63608. */
  63609. enableTexturesOffline: boolean;
  63610. /**
  63611. * Open the offline support and make it available
  63612. * @param successCallback defines the callback to call on success
  63613. * @param errorCallback defines the callback to call on error
  63614. */
  63615. open(successCallback: () => void, errorCallback: () => void): void;
  63616. /**
  63617. * Loads an image from the offline support
  63618. * @param url defines the url to load from
  63619. * @param image defines the target DOM image
  63620. */
  63621. loadImage(url: string, image: HTMLImageElement): void;
  63622. /**
  63623. * Loads a file from offline support
  63624. * @param url defines the URL to load from
  63625. * @param sceneLoaded defines a callback to call on success
  63626. * @param progressCallBack defines a callback to call when progress changed
  63627. * @param errorCallback defines a callback to call on error
  63628. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63629. */
  63630. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63631. }
  63632. }
  63633. declare module BABYLON {
  63634. /**
  63635. * A class serves as a medium between the observable and its observers
  63636. */
  63637. export class EventState {
  63638. /**
  63639. * Create a new EventState
  63640. * @param mask defines the mask associated with this state
  63641. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63642. * @param target defines the original target of the state
  63643. * @param currentTarget defines the current target of the state
  63644. */
  63645. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63646. /**
  63647. * Initialize the current event state
  63648. * @param mask defines the mask associated with this state
  63649. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63650. * @param target defines the original target of the state
  63651. * @param currentTarget defines the current target of the state
  63652. * @returns the current event state
  63653. */
  63654. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63655. /**
  63656. * An Observer can set this property to true to prevent subsequent observers of being notified
  63657. */
  63658. skipNextObservers: boolean;
  63659. /**
  63660. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63661. */
  63662. mask: number;
  63663. /**
  63664. * The object that originally notified the event
  63665. */
  63666. target?: any;
  63667. /**
  63668. * The current object in the bubbling phase
  63669. */
  63670. currentTarget?: any;
  63671. /**
  63672. * This will be populated with the return value of the last function that was executed.
  63673. * If it is the first function in the callback chain it will be the event data.
  63674. */
  63675. lastReturnValue?: any;
  63676. }
  63677. /**
  63678. * Represent an Observer registered to a given Observable object.
  63679. */
  63680. export class Observer<T> {
  63681. /**
  63682. * Defines the callback to call when the observer is notified
  63683. */
  63684. callback: (eventData: T, eventState: EventState) => void;
  63685. /**
  63686. * Defines the mask of the observer (used to filter notifications)
  63687. */
  63688. mask: number;
  63689. /**
  63690. * Defines the current scope used to restore the JS context
  63691. */
  63692. scope: any;
  63693. /** @hidden */
  63694. _willBeUnregistered: boolean;
  63695. /**
  63696. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63697. */
  63698. unregisterOnNextCall: boolean;
  63699. /**
  63700. * Creates a new observer
  63701. * @param callback defines the callback to call when the observer is notified
  63702. * @param mask defines the mask of the observer (used to filter notifications)
  63703. * @param scope defines the current scope used to restore the JS context
  63704. */
  63705. constructor(
  63706. /**
  63707. * Defines the callback to call when the observer is notified
  63708. */
  63709. callback: (eventData: T, eventState: EventState) => void,
  63710. /**
  63711. * Defines the mask of the observer (used to filter notifications)
  63712. */
  63713. mask: number,
  63714. /**
  63715. * Defines the current scope used to restore the JS context
  63716. */
  63717. scope?: any);
  63718. }
  63719. /**
  63720. * Represent a list of observers registered to multiple Observables object.
  63721. */
  63722. export class MultiObserver<T> {
  63723. private _observers;
  63724. private _observables;
  63725. /**
  63726. * Release associated resources
  63727. */
  63728. dispose(): void;
  63729. /**
  63730. * Raise a callback when one of the observable will notify
  63731. * @param observables defines a list of observables to watch
  63732. * @param callback defines the callback to call on notification
  63733. * @param mask defines the mask used to filter notifications
  63734. * @param scope defines the current scope used to restore the JS context
  63735. * @returns the new MultiObserver
  63736. */
  63737. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63738. }
  63739. /**
  63740. * The Observable class is a simple implementation of the Observable pattern.
  63741. *
  63742. * 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.
  63743. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63744. * 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).
  63745. * 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.
  63746. */
  63747. export class Observable<T> {
  63748. private _observers;
  63749. private _eventState;
  63750. private _onObserverAdded;
  63751. /**
  63752. * Creates a new observable
  63753. * @param onObserverAdded defines a callback to call when a new observer is added
  63754. */
  63755. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63756. /**
  63757. * Create a new Observer with the specified callback
  63758. * @param callback the callback that will be executed for that Observer
  63759. * @param mask the mask used to filter observers
  63760. * @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.
  63761. * @param scope optional scope for the callback to be called from
  63762. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63763. * @returns the new observer created for the callback
  63764. */
  63765. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63766. /**
  63767. * Create a new Observer with the specified callback and unregisters after the next notification
  63768. * @param callback the callback that will be executed for that Observer
  63769. * @returns the new observer created for the callback
  63770. */
  63771. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63772. /**
  63773. * Remove an Observer from the Observable object
  63774. * @param observer the instance of the Observer to remove
  63775. * @returns false if it doesn't belong to this Observable
  63776. */
  63777. remove(observer: Nullable<Observer<T>>): boolean;
  63778. /**
  63779. * Remove a callback from the Observable object
  63780. * @param callback the callback to remove
  63781. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63782. * @returns false if it doesn't belong to this Observable
  63783. */
  63784. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63785. private _deferUnregister;
  63786. private _remove;
  63787. /**
  63788. * Moves the observable to the top of the observer list making it get called first when notified
  63789. * @param observer the observer to move
  63790. */
  63791. makeObserverTopPriority(observer: Observer<T>): void;
  63792. /**
  63793. * Moves the observable to the bottom of the observer list making it get called last when notified
  63794. * @param observer the observer to move
  63795. */
  63796. makeObserverBottomPriority(observer: Observer<T>): void;
  63797. /**
  63798. * Notify all Observers by calling their respective callback with the given data
  63799. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63800. * @param eventData defines the data to send to all observers
  63801. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63802. * @param target defines the original target of the state
  63803. * @param currentTarget defines the current target of the state
  63804. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63805. */
  63806. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63807. /**
  63808. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63809. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63810. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63811. * and it is crucial that all callbacks will be executed.
  63812. * The order of the callbacks is kept, callbacks are not executed parallel.
  63813. *
  63814. * @param eventData The data to be sent to each callback
  63815. * @param mask is used to filter observers defaults to -1
  63816. * @param target defines the callback target (see EventState)
  63817. * @param currentTarget defines he current object in the bubbling phase
  63818. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63819. */
  63820. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63821. /**
  63822. * Notify a specific observer
  63823. * @param observer defines the observer to notify
  63824. * @param eventData defines the data to be sent to each callback
  63825. * @param mask is used to filter observers defaults to -1
  63826. */
  63827. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63828. /**
  63829. * Gets a boolean indicating if the observable has at least one observer
  63830. * @returns true is the Observable has at least one Observer registered
  63831. */
  63832. hasObservers(): boolean;
  63833. /**
  63834. * Clear the list of observers
  63835. */
  63836. clear(): void;
  63837. /**
  63838. * Clone the current observable
  63839. * @returns a new observable
  63840. */
  63841. clone(): Observable<T>;
  63842. /**
  63843. * Does this observable handles observer registered with a given mask
  63844. * @param mask defines the mask to be tested
  63845. * @return whether or not one observer registered with the given mask is handeled
  63846. **/
  63847. hasSpecificMask(mask?: number): boolean;
  63848. }
  63849. }
  63850. declare module BABYLON {
  63851. /**
  63852. * Class used to help managing file picking and drag'n'drop
  63853. * File Storage
  63854. */
  63855. export class FilesInputStore {
  63856. /**
  63857. * List of files ready to be loaded
  63858. */
  63859. static FilesToLoad: {
  63860. [key: string]: File;
  63861. };
  63862. }
  63863. }
  63864. declare module BABYLON {
  63865. /** Defines the cross module used constants to avoid circular dependncies */
  63866. export class Constants {
  63867. /** Defines that alpha blending is disabled */
  63868. static readonly ALPHA_DISABLE: number;
  63869. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  63870. static readonly ALPHA_ADD: number;
  63871. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  63872. static readonly ALPHA_COMBINE: number;
  63873. /** Defines that alpha blending to DEST - SRC * DEST */
  63874. static readonly ALPHA_SUBTRACT: number;
  63875. /** Defines that alpha blending to SRC * DEST */
  63876. static readonly ALPHA_MULTIPLY: number;
  63877. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  63878. static readonly ALPHA_MAXIMIZED: number;
  63879. /** Defines that alpha blending to SRC + DEST */
  63880. static readonly ALPHA_ONEONE: number;
  63881. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  63882. static readonly ALPHA_PREMULTIPLIED: number;
  63883. /**
  63884. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  63885. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  63886. */
  63887. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  63888. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  63889. static readonly ALPHA_INTERPOLATE: number;
  63890. /**
  63891. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  63892. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  63893. */
  63894. static readonly ALPHA_SCREENMODE: number;
  63895. /** Defines that the ressource is not delayed*/
  63896. static readonly DELAYLOADSTATE_NONE: number;
  63897. /** Defines that the ressource was successfully delay loaded */
  63898. static readonly DELAYLOADSTATE_LOADED: number;
  63899. /** Defines that the ressource is currently delay loading */
  63900. static readonly DELAYLOADSTATE_LOADING: number;
  63901. /** Defines that the ressource is delayed and has not started loading */
  63902. static readonly DELAYLOADSTATE_NOTLOADED: number;
  63903. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  63904. static readonly NEVER: number;
  63905. /** 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 */
  63906. static readonly ALWAYS: number;
  63907. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  63908. static readonly LESS: number;
  63909. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  63910. static readonly EQUAL: number;
  63911. /** 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 */
  63912. static readonly LEQUAL: number;
  63913. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  63914. static readonly GREATER: number;
  63915. /** 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 */
  63916. static readonly GEQUAL: number;
  63917. /** 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 */
  63918. static readonly NOTEQUAL: number;
  63919. /** Passed to stencilOperation to specify that stencil value must be kept */
  63920. static readonly KEEP: number;
  63921. /** Passed to stencilOperation to specify that stencil value must be replaced */
  63922. static readonly REPLACE: number;
  63923. /** Passed to stencilOperation to specify that stencil value must be incremented */
  63924. static readonly INCR: number;
  63925. /** Passed to stencilOperation to specify that stencil value must be decremented */
  63926. static readonly DECR: number;
  63927. /** Passed to stencilOperation to specify that stencil value must be inverted */
  63928. static readonly INVERT: number;
  63929. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  63930. static readonly INCR_WRAP: number;
  63931. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  63932. static readonly DECR_WRAP: number;
  63933. /** Texture is not repeating outside of 0..1 UVs */
  63934. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  63935. /** Texture is repeating outside of 0..1 UVs */
  63936. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  63937. /** Texture is repeating and mirrored */
  63938. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  63939. /** ALPHA */
  63940. static readonly TEXTUREFORMAT_ALPHA: number;
  63941. /** LUMINANCE */
  63942. static readonly TEXTUREFORMAT_LUMINANCE: number;
  63943. /** LUMINANCE_ALPHA */
  63944. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  63945. /** RGB */
  63946. static readonly TEXTUREFORMAT_RGB: number;
  63947. /** RGBA */
  63948. static readonly TEXTUREFORMAT_RGBA: number;
  63949. /** RED */
  63950. static readonly TEXTUREFORMAT_RED: number;
  63951. /** RED (2nd reference) */
  63952. static readonly TEXTUREFORMAT_R: number;
  63953. /** RG */
  63954. static readonly TEXTUREFORMAT_RG: number;
  63955. /** RED_INTEGER */
  63956. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  63957. /** RED_INTEGER (2nd reference) */
  63958. static readonly TEXTUREFORMAT_R_INTEGER: number;
  63959. /** RG_INTEGER */
  63960. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  63961. /** RGB_INTEGER */
  63962. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  63963. /** RGBA_INTEGER */
  63964. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  63965. /** UNSIGNED_BYTE */
  63966. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  63967. /** UNSIGNED_BYTE (2nd reference) */
  63968. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  63969. /** FLOAT */
  63970. static readonly TEXTURETYPE_FLOAT: number;
  63971. /** HALF_FLOAT */
  63972. static readonly TEXTURETYPE_HALF_FLOAT: number;
  63973. /** BYTE */
  63974. static readonly TEXTURETYPE_BYTE: number;
  63975. /** SHORT */
  63976. static readonly TEXTURETYPE_SHORT: number;
  63977. /** UNSIGNED_SHORT */
  63978. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  63979. /** INT */
  63980. static readonly TEXTURETYPE_INT: number;
  63981. /** UNSIGNED_INT */
  63982. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  63983. /** UNSIGNED_SHORT_4_4_4_4 */
  63984. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  63985. /** UNSIGNED_SHORT_5_5_5_1 */
  63986. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  63987. /** UNSIGNED_SHORT_5_6_5 */
  63988. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  63989. /** UNSIGNED_INT_2_10_10_10_REV */
  63990. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  63991. /** UNSIGNED_INT_24_8 */
  63992. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  63993. /** UNSIGNED_INT_10F_11F_11F_REV */
  63994. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  63995. /** UNSIGNED_INT_5_9_9_9_REV */
  63996. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  63997. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  63998. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  63999. /** nearest is mag = nearest and min = nearest and mip = linear */
  64000. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64001. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64002. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64003. /** Trilinear is mag = linear and min = linear and mip = linear */
  64004. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64005. /** nearest is mag = nearest and min = nearest and mip = linear */
  64006. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64007. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64008. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64009. /** Trilinear is mag = linear and min = linear and mip = linear */
  64010. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64011. /** mag = nearest and min = nearest and mip = nearest */
  64012. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64013. /** mag = nearest and min = linear and mip = nearest */
  64014. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64015. /** mag = nearest and min = linear and mip = linear */
  64016. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64017. /** mag = nearest and min = linear and mip = none */
  64018. static readonly TEXTURE_NEAREST_LINEAR: number;
  64019. /** mag = nearest and min = nearest and mip = none */
  64020. static readonly TEXTURE_NEAREST_NEAREST: number;
  64021. /** mag = linear and min = nearest and mip = nearest */
  64022. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64023. /** mag = linear and min = nearest and mip = linear */
  64024. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64025. /** mag = linear and min = linear and mip = none */
  64026. static readonly TEXTURE_LINEAR_LINEAR: number;
  64027. /** mag = linear and min = nearest and mip = none */
  64028. static readonly TEXTURE_LINEAR_NEAREST: number;
  64029. /** Explicit coordinates mode */
  64030. static readonly TEXTURE_EXPLICIT_MODE: number;
  64031. /** Spherical coordinates mode */
  64032. static readonly TEXTURE_SPHERICAL_MODE: number;
  64033. /** Planar coordinates mode */
  64034. static readonly TEXTURE_PLANAR_MODE: number;
  64035. /** Cubic coordinates mode */
  64036. static readonly TEXTURE_CUBIC_MODE: number;
  64037. /** Projection coordinates mode */
  64038. static readonly TEXTURE_PROJECTION_MODE: number;
  64039. /** Skybox coordinates mode */
  64040. static readonly TEXTURE_SKYBOX_MODE: number;
  64041. /** Inverse Cubic coordinates mode */
  64042. static readonly TEXTURE_INVCUBIC_MODE: number;
  64043. /** Equirectangular coordinates mode */
  64044. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64045. /** Equirectangular Fixed coordinates mode */
  64046. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64047. /** Equirectangular Fixed Mirrored coordinates mode */
  64048. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64049. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64050. static readonly SCALEMODE_FLOOR: number;
  64051. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64052. static readonly SCALEMODE_NEAREST: number;
  64053. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64054. static readonly SCALEMODE_CEILING: number;
  64055. /**
  64056. * The dirty texture flag value
  64057. */
  64058. static readonly MATERIAL_TextureDirtyFlag: number;
  64059. /**
  64060. * The dirty light flag value
  64061. */
  64062. static readonly MATERIAL_LightDirtyFlag: number;
  64063. /**
  64064. * The dirty fresnel flag value
  64065. */
  64066. static readonly MATERIAL_FresnelDirtyFlag: number;
  64067. /**
  64068. * The dirty attribute flag value
  64069. */
  64070. static readonly MATERIAL_AttributesDirtyFlag: number;
  64071. /**
  64072. * The dirty misc flag value
  64073. */
  64074. static readonly MATERIAL_MiscDirtyFlag: number;
  64075. /**
  64076. * The all dirty flag value
  64077. */
  64078. static readonly MATERIAL_AllDirtyFlag: number;
  64079. /**
  64080. * Returns the triangle fill mode
  64081. */
  64082. static readonly MATERIAL_TriangleFillMode: number;
  64083. /**
  64084. * Returns the wireframe mode
  64085. */
  64086. static readonly MATERIAL_WireFrameFillMode: number;
  64087. /**
  64088. * Returns the point fill mode
  64089. */
  64090. static readonly MATERIAL_PointFillMode: number;
  64091. /**
  64092. * Returns the point list draw mode
  64093. */
  64094. static readonly MATERIAL_PointListDrawMode: number;
  64095. /**
  64096. * Returns the line list draw mode
  64097. */
  64098. static readonly MATERIAL_LineListDrawMode: number;
  64099. /**
  64100. * Returns the line loop draw mode
  64101. */
  64102. static readonly MATERIAL_LineLoopDrawMode: number;
  64103. /**
  64104. * Returns the line strip draw mode
  64105. */
  64106. static readonly MATERIAL_LineStripDrawMode: number;
  64107. /**
  64108. * Returns the triangle strip draw mode
  64109. */
  64110. static readonly MATERIAL_TriangleStripDrawMode: number;
  64111. /**
  64112. * Returns the triangle fan draw mode
  64113. */
  64114. static readonly MATERIAL_TriangleFanDrawMode: number;
  64115. /**
  64116. * Stores the clock-wise side orientation
  64117. */
  64118. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64119. /**
  64120. * Stores the counter clock-wise side orientation
  64121. */
  64122. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64123. /**
  64124. * Nothing
  64125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64126. */
  64127. static readonly ACTION_NothingTrigger: number;
  64128. /**
  64129. * On pick
  64130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64131. */
  64132. static readonly ACTION_OnPickTrigger: number;
  64133. /**
  64134. * On left pick
  64135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64136. */
  64137. static readonly ACTION_OnLeftPickTrigger: number;
  64138. /**
  64139. * On right pick
  64140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64141. */
  64142. static readonly ACTION_OnRightPickTrigger: number;
  64143. /**
  64144. * On center pick
  64145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64146. */
  64147. static readonly ACTION_OnCenterPickTrigger: number;
  64148. /**
  64149. * On pick down
  64150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64151. */
  64152. static readonly ACTION_OnPickDownTrigger: number;
  64153. /**
  64154. * On double pick
  64155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64156. */
  64157. static readonly ACTION_OnDoublePickTrigger: number;
  64158. /**
  64159. * On pick up
  64160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64161. */
  64162. static readonly ACTION_OnPickUpTrigger: number;
  64163. /**
  64164. * On pick out.
  64165. * This trigger will only be raised if you also declared a OnPickDown
  64166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64167. */
  64168. static readonly ACTION_OnPickOutTrigger: number;
  64169. /**
  64170. * On long press
  64171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64172. */
  64173. static readonly ACTION_OnLongPressTrigger: number;
  64174. /**
  64175. * On pointer over
  64176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64177. */
  64178. static readonly ACTION_OnPointerOverTrigger: number;
  64179. /**
  64180. * On pointer out
  64181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64182. */
  64183. static readonly ACTION_OnPointerOutTrigger: number;
  64184. /**
  64185. * On every frame
  64186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64187. */
  64188. static readonly ACTION_OnEveryFrameTrigger: number;
  64189. /**
  64190. * On intersection enter
  64191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64192. */
  64193. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64194. /**
  64195. * On intersection exit
  64196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64197. */
  64198. static readonly ACTION_OnIntersectionExitTrigger: number;
  64199. /**
  64200. * On key down
  64201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64202. */
  64203. static readonly ACTION_OnKeyDownTrigger: number;
  64204. /**
  64205. * On key up
  64206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64207. */
  64208. static readonly ACTION_OnKeyUpTrigger: number;
  64209. /**
  64210. * Billboard mode will only apply to Y axis
  64211. */
  64212. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64213. /**
  64214. * Billboard mode will apply to all axes
  64215. */
  64216. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64217. /**
  64218. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64219. */
  64220. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64221. /**
  64222. * Gets or sets base Assets URL
  64223. */
  64224. static readonly PARTICLES_BaseAssetsUrl: string;
  64225. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64226. * Test order :
  64227. * Is the bounding sphere outside the frustum ?
  64228. * If not, are the bounding box vertices outside the frustum ?
  64229. * It not, then the cullable object is in the frustum.
  64230. */
  64231. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64232. /** Culling strategy : Bounding Sphere Only.
  64233. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64234. * It's also less accurate than the standard because some not visible objects can still be selected.
  64235. * Test : is the bounding sphere outside the frustum ?
  64236. * If not, then the cullable object is in the frustum.
  64237. */
  64238. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64239. /** Culling strategy : Optimistic Inclusion.
  64240. * This in an inclusion test first, then the standard exclusion test.
  64241. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64242. * 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.
  64243. * Anyway, it's as accurate as the standard strategy.
  64244. * Test :
  64245. * Is the cullable object bounding sphere center in the frustum ?
  64246. * If not, apply the default culling strategy.
  64247. */
  64248. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64249. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64250. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64251. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64252. * 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.
  64253. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64254. * Test :
  64255. * Is the cullable object bounding sphere center in the frustum ?
  64256. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64257. */
  64258. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64259. /**
  64260. * No logging while loading
  64261. */
  64262. static readonly SCENELOADER_NO_LOGGING: number;
  64263. /**
  64264. * Minimal logging while loading
  64265. */
  64266. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64267. /**
  64268. * Summary logging while loading
  64269. */
  64270. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64271. /**
  64272. * Detailled logging while loading
  64273. */
  64274. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64275. }
  64276. }
  64277. declare module BABYLON {
  64278. /**
  64279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64280. * Babylon.js
  64281. */
  64282. export class DomManagement {
  64283. /**
  64284. * Checks if the window object exists
  64285. * @returns true if the window object exists
  64286. */
  64287. static IsWindowObjectExist(): boolean;
  64288. /**
  64289. * Extracts text content from a DOM element hierarchy
  64290. * @param element defines the root element
  64291. * @returns a string
  64292. */
  64293. static GetDOMTextContent(element: HTMLElement): string;
  64294. }
  64295. }
  64296. declare module BABYLON {
  64297. /**
  64298. * Logger used througouht the application to allow configuration of
  64299. * the log level required for the messages.
  64300. */
  64301. export class Logger {
  64302. /**
  64303. * No log
  64304. */
  64305. static readonly NoneLogLevel: number;
  64306. /**
  64307. * Only message logs
  64308. */
  64309. static readonly MessageLogLevel: number;
  64310. /**
  64311. * Only warning logs
  64312. */
  64313. static readonly WarningLogLevel: number;
  64314. /**
  64315. * Only error logs
  64316. */
  64317. static readonly ErrorLogLevel: number;
  64318. /**
  64319. * All logs
  64320. */
  64321. static readonly AllLogLevel: number;
  64322. private static _LogCache;
  64323. /**
  64324. * Gets a value indicating the number of loading errors
  64325. * @ignorenaming
  64326. */
  64327. static errorsCount: number;
  64328. /**
  64329. * Callback called when a new log is added
  64330. */
  64331. static OnNewCacheEntry: (entry: string) => void;
  64332. private static _AddLogEntry;
  64333. private static _FormatMessage;
  64334. private static _LogDisabled;
  64335. private static _LogEnabled;
  64336. private static _WarnDisabled;
  64337. private static _WarnEnabled;
  64338. private static _ErrorDisabled;
  64339. private static _ErrorEnabled;
  64340. /**
  64341. * Log a message to the console
  64342. */
  64343. static Log: (message: string) => void;
  64344. /**
  64345. * Write a warning message to the console
  64346. */
  64347. static Warn: (message: string) => void;
  64348. /**
  64349. * Write an error message to the console
  64350. */
  64351. static Error: (message: string) => void;
  64352. /**
  64353. * Gets current log cache (list of logs)
  64354. */
  64355. static readonly LogCache: string;
  64356. /**
  64357. * Clears the log cache
  64358. */
  64359. static ClearLogCache(): void;
  64360. /**
  64361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64362. */
  64363. static LogLevels: number;
  64364. }
  64365. }
  64366. declare module BABYLON {
  64367. /** @hidden */
  64368. export class _TypeStore {
  64369. /** @hidden */
  64370. static RegisteredTypes: {
  64371. [key: string]: Object;
  64372. };
  64373. /** @hidden */
  64374. static GetClass(fqdn: string): any;
  64375. }
  64376. }
  64377. declare module BABYLON {
  64378. /**
  64379. * Class containing a set of static utilities functions for deep copy.
  64380. */
  64381. export class DeepCopier {
  64382. /**
  64383. * Tries to copy an object by duplicating every property
  64384. * @param source defines the source object
  64385. * @param destination defines the target object
  64386. * @param doNotCopyList defines a list of properties to avoid
  64387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64388. */
  64389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64390. }
  64391. }
  64392. declare module BABYLON {
  64393. /**
  64394. * Class containing a set of static utilities functions for precision date
  64395. */
  64396. export class PrecisionDate {
  64397. /**
  64398. * Gets either window.performance.now() if supported or Date.now() else
  64399. */
  64400. static readonly Now: number;
  64401. }
  64402. }
  64403. declare module BABYLON {
  64404. /** @hidden */
  64405. export class _DevTools {
  64406. static WarnImport(name: string): string;
  64407. }
  64408. }
  64409. declare module BABYLON {
  64410. /**
  64411. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64412. */
  64413. export class WebRequest {
  64414. private _xhr;
  64415. /**
  64416. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64417. * i.e. when loading files, where the server/service expects an Authorization header
  64418. */
  64419. static CustomRequestHeaders: {
  64420. [key: string]: string;
  64421. };
  64422. /**
  64423. * Add callback functions in this array to update all the requests before they get sent to the network
  64424. */
  64425. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64426. private _injectCustomRequestHeaders;
  64427. /**
  64428. * Gets or sets a function to be called when loading progress changes
  64429. */
  64430. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64431. /**
  64432. * Returns client's state
  64433. */
  64434. readonly readyState: number;
  64435. /**
  64436. * Returns client's status
  64437. */
  64438. readonly status: number;
  64439. /**
  64440. * Returns client's status as a text
  64441. */
  64442. readonly statusText: string;
  64443. /**
  64444. * Returns client's response
  64445. */
  64446. readonly response: any;
  64447. /**
  64448. * Returns client's response url
  64449. */
  64450. readonly responseURL: string;
  64451. /**
  64452. * Returns client's response as text
  64453. */
  64454. readonly responseText: string;
  64455. /**
  64456. * Gets or sets the expected response type
  64457. */
  64458. responseType: XMLHttpRequestResponseType;
  64459. /** @hidden */
  64460. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64461. /** @hidden */
  64462. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64463. /**
  64464. * Cancels any network activity
  64465. */
  64466. abort(): void;
  64467. /**
  64468. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64469. * @param body defines an optional request body
  64470. */
  64471. send(body?: Document | BodyInit | null): void;
  64472. /**
  64473. * Sets the request method, request URL
  64474. * @param method defines the method to use (GET, POST, etc..)
  64475. * @param url defines the url to connect with
  64476. */
  64477. open(method: string, url: string): void;
  64478. }
  64479. }
  64480. declare module BABYLON {
  64481. /**
  64482. * Class used to evalaute queries containing `and` and `or` operators
  64483. */
  64484. export class AndOrNotEvaluator {
  64485. /**
  64486. * Evaluate a query
  64487. * @param query defines the query to evaluate
  64488. * @param evaluateCallback defines the callback used to filter result
  64489. * @returns true if the query matches
  64490. */
  64491. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64492. private static _HandleParenthesisContent;
  64493. private static _SimplifyNegation;
  64494. }
  64495. }
  64496. declare module BABYLON {
  64497. /**
  64498. * Class used to store custom tags
  64499. */
  64500. export class Tags {
  64501. /**
  64502. * Adds support for tags on the given object
  64503. * @param obj defines the object to use
  64504. */
  64505. static EnableFor(obj: any): void;
  64506. /**
  64507. * Removes tags support
  64508. * @param obj defines the object to use
  64509. */
  64510. static DisableFor(obj: any): void;
  64511. /**
  64512. * Gets a boolean indicating if the given object has tags
  64513. * @param obj defines the object to use
  64514. * @returns a boolean
  64515. */
  64516. static HasTags(obj: any): boolean;
  64517. /**
  64518. * Gets the tags available on a given object
  64519. * @param obj defines the object to use
  64520. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64521. * @returns the tags
  64522. */
  64523. static GetTags(obj: any, asString?: boolean): any;
  64524. /**
  64525. * Adds tags to an object
  64526. * @param obj defines the object to use
  64527. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64528. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64529. */
  64530. static AddTagsTo(obj: any, tagsString: string): void;
  64531. /**
  64532. * @hidden
  64533. */
  64534. static _AddTagTo(obj: any, tag: string): void;
  64535. /**
  64536. * Removes specific tags from a specific object
  64537. * @param obj defines the object to use
  64538. * @param tagsString defines the tags to remove
  64539. */
  64540. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64541. /**
  64542. * @hidden
  64543. */
  64544. static _RemoveTagFrom(obj: any, tag: string): void;
  64545. /**
  64546. * Defines if tags hosted on an object match a given query
  64547. * @param obj defines the object to use
  64548. * @param tagsQuery defines the tag query
  64549. * @returns a boolean
  64550. */
  64551. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64552. }
  64553. }
  64554. declare module BABYLON {
  64555. /**
  64556. * Manages the defines for the Material
  64557. */
  64558. export class MaterialDefines {
  64559. private _keys;
  64560. private _isDirty;
  64561. /** @hidden */
  64562. _renderId: number;
  64563. /** @hidden */
  64564. _areLightsDirty: boolean;
  64565. /** @hidden */
  64566. _areAttributesDirty: boolean;
  64567. /** @hidden */
  64568. _areTexturesDirty: boolean;
  64569. /** @hidden */
  64570. _areFresnelDirty: boolean;
  64571. /** @hidden */
  64572. _areMiscDirty: boolean;
  64573. /** @hidden */
  64574. _areImageProcessingDirty: boolean;
  64575. /** @hidden */
  64576. _normals: boolean;
  64577. /** @hidden */
  64578. _uvs: boolean;
  64579. /** @hidden */
  64580. _needNormals: boolean;
  64581. /** @hidden */
  64582. _needUVs: boolean;
  64583. /**
  64584. * Specifies if the material needs to be re-calculated
  64585. */
  64586. readonly isDirty: boolean;
  64587. /**
  64588. * Marks the material to indicate that it has been re-calculated
  64589. */
  64590. markAsProcessed(): void;
  64591. /**
  64592. * Marks the material to indicate that it needs to be re-calculated
  64593. */
  64594. markAsUnprocessed(): void;
  64595. /**
  64596. * Marks the material to indicate all of its defines need to be re-calculated
  64597. */
  64598. markAllAsDirty(): void;
  64599. /**
  64600. * Marks the material to indicate that image processing needs to be re-calculated
  64601. */
  64602. markAsImageProcessingDirty(): void;
  64603. /**
  64604. * Marks the material to indicate the lights need to be re-calculated
  64605. */
  64606. markAsLightDirty(): void;
  64607. /**
  64608. * Marks the attribute state as changed
  64609. */
  64610. markAsAttributesDirty(): void;
  64611. /**
  64612. * Marks the texture state as changed
  64613. */
  64614. markAsTexturesDirty(): void;
  64615. /**
  64616. * Marks the fresnel state as changed
  64617. */
  64618. markAsFresnelDirty(): void;
  64619. /**
  64620. * Marks the misc state as changed
  64621. */
  64622. markAsMiscDirty(): void;
  64623. /**
  64624. * Rebuilds the material defines
  64625. */
  64626. rebuild(): void;
  64627. /**
  64628. * Specifies if two material defines are equal
  64629. * @param other - A material define instance to compare to
  64630. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64631. */
  64632. isEqual(other: MaterialDefines): boolean;
  64633. /**
  64634. * Clones this instance's defines to another instance
  64635. * @param other - material defines to clone values to
  64636. */
  64637. cloneTo(other: MaterialDefines): void;
  64638. /**
  64639. * Resets the material define values
  64640. */
  64641. reset(): void;
  64642. /**
  64643. * Converts the material define values to a string
  64644. * @returns - String of material define information
  64645. */
  64646. toString(): string;
  64647. }
  64648. }
  64649. declare module BABYLON {
  64650. /**
  64651. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64652. */
  64653. export class PerformanceMonitor {
  64654. private _enabled;
  64655. private _rollingFrameTime;
  64656. private _lastFrameTimeMs;
  64657. /**
  64658. * constructor
  64659. * @param frameSampleSize The number of samples required to saturate the sliding window
  64660. */
  64661. constructor(frameSampleSize?: number);
  64662. /**
  64663. * Samples current frame
  64664. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64665. */
  64666. sampleFrame(timeMs?: number): void;
  64667. /**
  64668. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64669. */
  64670. readonly averageFrameTime: number;
  64671. /**
  64672. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64673. */
  64674. readonly averageFrameTimeVariance: number;
  64675. /**
  64676. * Returns the frame time of the most recent frame
  64677. */
  64678. readonly instantaneousFrameTime: number;
  64679. /**
  64680. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64681. */
  64682. readonly averageFPS: number;
  64683. /**
  64684. * Returns the average framerate in frames per second using the most recent frame time
  64685. */
  64686. readonly instantaneousFPS: number;
  64687. /**
  64688. * Returns true if enough samples have been taken to completely fill the sliding window
  64689. */
  64690. readonly isSaturated: boolean;
  64691. /**
  64692. * Enables contributions to the sliding window sample set
  64693. */
  64694. enable(): void;
  64695. /**
  64696. * Disables contributions to the sliding window sample set
  64697. * Samples will not be interpolated over the disabled period
  64698. */
  64699. disable(): void;
  64700. /**
  64701. * Returns true if sampling is enabled
  64702. */
  64703. readonly isEnabled: boolean;
  64704. /**
  64705. * Resets performance monitor
  64706. */
  64707. reset(): void;
  64708. }
  64709. /**
  64710. * RollingAverage
  64711. *
  64712. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64713. */
  64714. export class RollingAverage {
  64715. /**
  64716. * Current average
  64717. */
  64718. average: number;
  64719. /**
  64720. * Current variance
  64721. */
  64722. variance: number;
  64723. protected _samples: Array<number>;
  64724. protected _sampleCount: number;
  64725. protected _pos: number;
  64726. protected _m2: number;
  64727. /**
  64728. * constructor
  64729. * @param length The number of samples required to saturate the sliding window
  64730. */
  64731. constructor(length: number);
  64732. /**
  64733. * Adds a sample to the sample set
  64734. * @param v The sample value
  64735. */
  64736. add(v: number): void;
  64737. /**
  64738. * Returns previously added values or null if outside of history or outside the sliding window domain
  64739. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64740. * @return Value previously recorded with add() or null if outside of range
  64741. */
  64742. history(i: number): number;
  64743. /**
  64744. * Returns true if enough samples have been taken to completely fill the sliding window
  64745. * @return true if sample-set saturated
  64746. */
  64747. isSaturated(): boolean;
  64748. /**
  64749. * Resets the rolling average (equivalent to 0 samples taken so far)
  64750. */
  64751. reset(): void;
  64752. /**
  64753. * Wraps a value around the sample range boundaries
  64754. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64755. * @return Wrapped position in sample range
  64756. */
  64757. protected _wrapPosition(i: number): number;
  64758. }
  64759. }
  64760. declare module BABYLON {
  64761. /**
  64762. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64763. * The underlying implementation relies on an associative array to ensure the best performances.
  64764. * The value can be anything including 'null' but except 'undefined'
  64765. */
  64766. export class StringDictionary<T> {
  64767. /**
  64768. * This will clear this dictionary and copy the content from the 'source' one.
  64769. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64770. * @param source the dictionary to take the content from and copy to this dictionary
  64771. */
  64772. copyFrom(source: StringDictionary<T>): void;
  64773. /**
  64774. * Get a value based from its key
  64775. * @param key the given key to get the matching value from
  64776. * @return the value if found, otherwise undefined is returned
  64777. */
  64778. get(key: string): T | undefined;
  64779. /**
  64780. * Get a value from its key or add it if it doesn't exist.
  64781. * This method will ensure you that a given key/data will be present in the dictionary.
  64782. * @param key the given key to get the matching value from
  64783. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64784. * The factory will only be invoked if there's no data for the given key.
  64785. * @return the value corresponding to the key.
  64786. */
  64787. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64788. /**
  64789. * Get a value from its key if present in the dictionary otherwise add it
  64790. * @param key the key to get the value from
  64791. * @param val if there's no such key/value pair in the dictionary add it with this value
  64792. * @return the value corresponding to the key
  64793. */
  64794. getOrAdd(key: string, val: T): T;
  64795. /**
  64796. * Check if there's a given key in the dictionary
  64797. * @param key the key to check for
  64798. * @return true if the key is present, false otherwise
  64799. */
  64800. contains(key: string): boolean;
  64801. /**
  64802. * Add a new key and its corresponding value
  64803. * @param key the key to add
  64804. * @param value the value corresponding to the key
  64805. * @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
  64806. */
  64807. add(key: string, value: T): boolean;
  64808. /**
  64809. * Update a specific value associated to a key
  64810. * @param key defines the key to use
  64811. * @param value defines the value to store
  64812. * @returns true if the value was updated (or false if the key was not found)
  64813. */
  64814. set(key: string, value: T): boolean;
  64815. /**
  64816. * Get the element of the given key and remove it from the dictionary
  64817. * @param key defines the key to search
  64818. * @returns the value associated with the key or null if not found
  64819. */
  64820. getAndRemove(key: string): Nullable<T>;
  64821. /**
  64822. * Remove a key/value from the dictionary.
  64823. * @param key the key to remove
  64824. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64825. */
  64826. remove(key: string): boolean;
  64827. /**
  64828. * Clear the whole content of the dictionary
  64829. */
  64830. clear(): void;
  64831. /**
  64832. * Gets the current count
  64833. */
  64834. readonly count: number;
  64835. /**
  64836. * Execute a callback on each key/val of the dictionary.
  64837. * Note that you can remove any element in this dictionary in the callback implementation
  64838. * @param callback the callback to execute on a given key/value pair
  64839. */
  64840. forEach(callback: (key: string, val: T) => void): void;
  64841. /**
  64842. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64843. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64844. * Note that you can remove any element in this dictionary in the callback implementation
  64845. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64846. * @returns the first item
  64847. */
  64848. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64849. private _count;
  64850. private _data;
  64851. }
  64852. }
  64853. declare module BABYLON {
  64854. /**
  64855. * Helper class that provides a small promise polyfill
  64856. */
  64857. export class PromisePolyfill {
  64858. /**
  64859. * Static function used to check if the polyfill is required
  64860. * If this is the case then the function will inject the polyfill to window.Promise
  64861. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  64862. */
  64863. static Apply(force?: boolean): void;
  64864. }
  64865. }
  64866. declare module BABYLON {
  64867. /**
  64868. * Class used to store data that will be store in GPU memory
  64869. */
  64870. export class Buffer {
  64871. private _engine;
  64872. private _buffer;
  64873. /** @hidden */
  64874. _data: Nullable<DataArray>;
  64875. private _updatable;
  64876. private _instanced;
  64877. /**
  64878. * Gets the byte stride.
  64879. */
  64880. readonly byteStride: number;
  64881. /**
  64882. * Constructor
  64883. * @param engine the engine
  64884. * @param data the data to use for this buffer
  64885. * @param updatable whether the data is updatable
  64886. * @param stride the stride (optional)
  64887. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  64888. * @param instanced whether the buffer is instanced (optional)
  64889. * @param useBytes set to true if the stride in in bytes (optional)
  64890. */
  64891. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  64892. /**
  64893. * Create a new VertexBuffer based on the current buffer
  64894. * @param kind defines the vertex buffer kind (position, normal, etc.)
  64895. * @param offset defines offset in the buffer (0 by default)
  64896. * @param size defines the size in floats of attributes (position is 3 for instance)
  64897. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  64898. * @param instanced defines if the vertex buffer contains indexed data
  64899. * @param useBytes defines if the offset and stride are in bytes
  64900. * @returns the new vertex buffer
  64901. */
  64902. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  64903. /**
  64904. * Gets a boolean indicating if the Buffer is updatable?
  64905. * @returns true if the buffer is updatable
  64906. */
  64907. isUpdatable(): boolean;
  64908. /**
  64909. * Gets current buffer's data
  64910. * @returns a DataArray or null
  64911. */
  64912. getData(): Nullable<DataArray>;
  64913. /**
  64914. * Gets underlying native buffer
  64915. * @returns underlying native buffer
  64916. */
  64917. getBuffer(): Nullable<WebGLBuffer>;
  64918. /**
  64919. * Gets the stride in float32 units (i.e. byte stride / 4).
  64920. * May not be an integer if the byte stride is not divisible by 4.
  64921. * DEPRECATED. Use byteStride instead.
  64922. * @returns the stride in float32 units
  64923. */
  64924. getStrideSize(): number;
  64925. /**
  64926. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  64927. * @param data defines the data to store
  64928. */
  64929. create(data?: Nullable<DataArray>): void;
  64930. /** @hidden */
  64931. _rebuild(): void;
  64932. /**
  64933. * Update current buffer data
  64934. * @param data defines the data to store
  64935. */
  64936. update(data: DataArray): void;
  64937. /**
  64938. * Updates the data directly.
  64939. * @param data the new data
  64940. * @param offset the new offset
  64941. * @param vertexCount the vertex count (optional)
  64942. * @param useBytes set to true if the offset is in bytes
  64943. */
  64944. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  64945. /**
  64946. * Release all resources
  64947. */
  64948. dispose(): void;
  64949. }
  64950. /**
  64951. * Specialized buffer used to store vertex data
  64952. */
  64953. export class VertexBuffer {
  64954. /** @hidden */
  64955. _buffer: Buffer;
  64956. private _kind;
  64957. private _size;
  64958. private _ownsBuffer;
  64959. private _instanced;
  64960. private _instanceDivisor;
  64961. /**
  64962. * The byte type.
  64963. */
  64964. static readonly BYTE: number;
  64965. /**
  64966. * The unsigned byte type.
  64967. */
  64968. static readonly UNSIGNED_BYTE: number;
  64969. /**
  64970. * The short type.
  64971. */
  64972. static readonly SHORT: number;
  64973. /**
  64974. * The unsigned short type.
  64975. */
  64976. static readonly UNSIGNED_SHORT: number;
  64977. /**
  64978. * The integer type.
  64979. */
  64980. static readonly INT: number;
  64981. /**
  64982. * The unsigned integer type.
  64983. */
  64984. static readonly UNSIGNED_INT: number;
  64985. /**
  64986. * The float type.
  64987. */
  64988. static readonly FLOAT: number;
  64989. /**
  64990. * Gets or sets the instance divisor when in instanced mode
  64991. */
  64992. instanceDivisor: number;
  64993. /**
  64994. * Gets the byte stride.
  64995. */
  64996. readonly byteStride: number;
  64997. /**
  64998. * Gets the byte offset.
  64999. */
  65000. readonly byteOffset: number;
  65001. /**
  65002. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65003. */
  65004. readonly normalized: boolean;
  65005. /**
  65006. * Gets the data type of each component in the array.
  65007. */
  65008. readonly type: number;
  65009. /**
  65010. * Constructor
  65011. * @param engine the engine
  65012. * @param data the data to use for this vertex buffer
  65013. * @param kind the vertex buffer kind
  65014. * @param updatable whether the data is updatable
  65015. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65016. * @param stride the stride (optional)
  65017. * @param instanced whether the buffer is instanced (optional)
  65018. * @param offset the offset of the data (optional)
  65019. * @param size the number of components (optional)
  65020. * @param type the type of the component (optional)
  65021. * @param normalized whether the data contains normalized data (optional)
  65022. * @param useBytes set to true if stride and offset are in bytes (optional)
  65023. */
  65024. 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);
  65025. /** @hidden */
  65026. _rebuild(): void;
  65027. /**
  65028. * Returns the kind of the VertexBuffer (string)
  65029. * @returns a string
  65030. */
  65031. getKind(): string;
  65032. /**
  65033. * Gets a boolean indicating if the VertexBuffer is updatable?
  65034. * @returns true if the buffer is updatable
  65035. */
  65036. isUpdatable(): boolean;
  65037. /**
  65038. * Gets current buffer's data
  65039. * @returns a DataArray or null
  65040. */
  65041. getData(): Nullable<DataArray>;
  65042. /**
  65043. * Gets underlying native buffer
  65044. * @returns underlying native buffer
  65045. */
  65046. getBuffer(): Nullable<WebGLBuffer>;
  65047. /**
  65048. * Gets the stride in float32 units (i.e. byte stride / 4).
  65049. * May not be an integer if the byte stride is not divisible by 4.
  65050. * DEPRECATED. Use byteStride instead.
  65051. * @returns the stride in float32 units
  65052. */
  65053. getStrideSize(): number;
  65054. /**
  65055. * Returns the offset as a multiple of the type byte length.
  65056. * DEPRECATED. Use byteOffset instead.
  65057. * @returns the offset in bytes
  65058. */
  65059. getOffset(): number;
  65060. /**
  65061. * Returns the number of components per vertex attribute (integer)
  65062. * @returns the size in float
  65063. */
  65064. getSize(): number;
  65065. /**
  65066. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65067. * @returns true if this buffer is instanced
  65068. */
  65069. getIsInstanced(): boolean;
  65070. /**
  65071. * Returns the instancing divisor, zero for non-instanced (integer).
  65072. * @returns a number
  65073. */
  65074. getInstanceDivisor(): number;
  65075. /**
  65076. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65077. * @param data defines the data to store
  65078. */
  65079. create(data?: DataArray): void;
  65080. /**
  65081. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65082. * This function will create a new buffer if the current one is not updatable
  65083. * @param data defines the data to store
  65084. */
  65085. update(data: DataArray): void;
  65086. /**
  65087. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65088. * Returns the directly updated WebGLBuffer.
  65089. * @param data the new data
  65090. * @param offset the new offset
  65091. * @param useBytes set to true if the offset is in bytes
  65092. */
  65093. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65094. /**
  65095. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65096. */
  65097. dispose(): void;
  65098. /**
  65099. * Enumerates each value of this vertex buffer as numbers.
  65100. * @param count the number of values to enumerate
  65101. * @param callback the callback function called for each value
  65102. */
  65103. forEach(count: number, callback: (value: number, index: number) => void): void;
  65104. /**
  65105. * Positions
  65106. */
  65107. static readonly PositionKind: string;
  65108. /**
  65109. * Normals
  65110. */
  65111. static readonly NormalKind: string;
  65112. /**
  65113. * Tangents
  65114. */
  65115. static readonly TangentKind: string;
  65116. /**
  65117. * Texture coordinates
  65118. */
  65119. static readonly UVKind: string;
  65120. /**
  65121. * Texture coordinates 2
  65122. */
  65123. static readonly UV2Kind: string;
  65124. /**
  65125. * Texture coordinates 3
  65126. */
  65127. static readonly UV3Kind: string;
  65128. /**
  65129. * Texture coordinates 4
  65130. */
  65131. static readonly UV4Kind: string;
  65132. /**
  65133. * Texture coordinates 5
  65134. */
  65135. static readonly UV5Kind: string;
  65136. /**
  65137. * Texture coordinates 6
  65138. */
  65139. static readonly UV6Kind: string;
  65140. /**
  65141. * Colors
  65142. */
  65143. static readonly ColorKind: string;
  65144. /**
  65145. * Matrix indices (for bones)
  65146. */
  65147. static readonly MatricesIndicesKind: string;
  65148. /**
  65149. * Matrix weights (for bones)
  65150. */
  65151. static readonly MatricesWeightsKind: string;
  65152. /**
  65153. * Additional matrix indices (for bones)
  65154. */
  65155. static readonly MatricesIndicesExtraKind: string;
  65156. /**
  65157. * Additional matrix weights (for bones)
  65158. */
  65159. static readonly MatricesWeightsExtraKind: string;
  65160. /**
  65161. * Deduces the stride given a kind.
  65162. * @param kind The kind string to deduce
  65163. * @returns The deduced stride
  65164. */
  65165. static DeduceStride(kind: string): number;
  65166. /**
  65167. * Gets the byte length of the given type.
  65168. * @param type the type
  65169. * @returns the number of bytes
  65170. */
  65171. static GetTypeByteLength(type: number): number;
  65172. /**
  65173. * Enumerates each value of the given parameters as numbers.
  65174. * @param data the data to enumerate
  65175. * @param byteOffset the byte offset of the data
  65176. * @param byteStride the byte stride of the data
  65177. * @param componentCount the number of components per element
  65178. * @param componentType the type of the component
  65179. * @param count the total number of components
  65180. * @param normalized whether the data is normalized
  65181. * @param callback the callback function called for each value
  65182. */
  65183. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65184. private static _GetFloatValue;
  65185. }
  65186. }
  65187. declare module BABYLON {
  65188. /**
  65189. * Class representing spherical polynomial coefficients to the 3rd degree
  65190. */
  65191. export class SphericalPolynomial {
  65192. /**
  65193. * The x coefficients of the spherical polynomial
  65194. */
  65195. x: Vector3;
  65196. /**
  65197. * The y coefficients of the spherical polynomial
  65198. */
  65199. y: Vector3;
  65200. /**
  65201. * The z coefficients of the spherical polynomial
  65202. */
  65203. z: Vector3;
  65204. /**
  65205. * The xx coefficients of the spherical polynomial
  65206. */
  65207. xx: Vector3;
  65208. /**
  65209. * The yy coefficients of the spherical polynomial
  65210. */
  65211. yy: Vector3;
  65212. /**
  65213. * The zz coefficients of the spherical polynomial
  65214. */
  65215. zz: Vector3;
  65216. /**
  65217. * The xy coefficients of the spherical polynomial
  65218. */
  65219. xy: Vector3;
  65220. /**
  65221. * The yz coefficients of the spherical polynomial
  65222. */
  65223. yz: Vector3;
  65224. /**
  65225. * The zx coefficients of the spherical polynomial
  65226. */
  65227. zx: Vector3;
  65228. /**
  65229. * Adds an ambient color to the spherical polynomial
  65230. * @param color the color to add
  65231. */
  65232. addAmbient(color: Color3): void;
  65233. /**
  65234. * Scales the spherical polynomial by the given amount
  65235. * @param scale the amount to scale
  65236. */
  65237. scale(scale: number): void;
  65238. /**
  65239. * Gets the spherical polynomial from harmonics
  65240. * @param harmonics the spherical harmonics
  65241. * @returns the spherical polynomial
  65242. */
  65243. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65244. /**
  65245. * Constructs a spherical polynomial from an array.
  65246. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65247. * @returns the spherical polynomial
  65248. */
  65249. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65250. }
  65251. /**
  65252. * Class representing spherical harmonics coefficients to the 3rd degree
  65253. */
  65254. export class SphericalHarmonics {
  65255. /**
  65256. * The l0,0 coefficients of the spherical harmonics
  65257. */
  65258. l00: Vector3;
  65259. /**
  65260. * The l1,-1 coefficients of the spherical harmonics
  65261. */
  65262. l1_1: Vector3;
  65263. /**
  65264. * The l1,0 coefficients of the spherical harmonics
  65265. */
  65266. l10: Vector3;
  65267. /**
  65268. * The l1,1 coefficients of the spherical harmonics
  65269. */
  65270. l11: Vector3;
  65271. /**
  65272. * The l2,-2 coefficients of the spherical harmonics
  65273. */
  65274. l2_2: Vector3;
  65275. /**
  65276. * The l2,-1 coefficients of the spherical harmonics
  65277. */
  65278. l2_1: Vector3;
  65279. /**
  65280. * The l2,0 coefficients of the spherical harmonics
  65281. */
  65282. l20: Vector3;
  65283. /**
  65284. * The l2,1 coefficients of the spherical harmonics
  65285. */
  65286. l21: Vector3;
  65287. /**
  65288. * The l2,2 coefficients of the spherical harmonics
  65289. */
  65290. lL22: Vector3;
  65291. /**
  65292. * Adds a light to the spherical harmonics
  65293. * @param direction the direction of the light
  65294. * @param color the color of the light
  65295. * @param deltaSolidAngle the delta solid angle of the light
  65296. */
  65297. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65298. /**
  65299. * Scales the spherical harmonics by the given amount
  65300. * @param scale the amount to scale
  65301. */
  65302. scale(scale: number): void;
  65303. /**
  65304. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65305. *
  65306. * ```
  65307. * E_lm = A_l * L_lm
  65308. * ```
  65309. *
  65310. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65311. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65312. * the scaling factors are given in equation 9.
  65313. */
  65314. convertIncidentRadianceToIrradiance(): void;
  65315. /**
  65316. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65317. *
  65318. * ```
  65319. * L = (1/pi) * E * rho
  65320. * ```
  65321. *
  65322. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65323. */
  65324. convertIrradianceToLambertianRadiance(): void;
  65325. /**
  65326. * Gets the spherical harmonics from polynomial
  65327. * @param polynomial the spherical polynomial
  65328. * @returns the spherical harmonics
  65329. */
  65330. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65331. /**
  65332. * Constructs a spherical harmonics from an array.
  65333. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65334. * @returns the spherical harmonics
  65335. */
  65336. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65337. }
  65338. }
  65339. declare module BABYLON {
  65340. /**
  65341. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65342. */
  65343. export interface CubeMapInfo {
  65344. /**
  65345. * The pixel array for the front face.
  65346. * This is stored in format, left to right, up to down format.
  65347. */
  65348. front: Nullable<ArrayBufferView>;
  65349. /**
  65350. * The pixel array for the back face.
  65351. * This is stored in format, left to right, up to down format.
  65352. */
  65353. back: Nullable<ArrayBufferView>;
  65354. /**
  65355. * The pixel array for the left face.
  65356. * This is stored in format, left to right, up to down format.
  65357. */
  65358. left: Nullable<ArrayBufferView>;
  65359. /**
  65360. * The pixel array for the right face.
  65361. * This is stored in format, left to right, up to down format.
  65362. */
  65363. right: Nullable<ArrayBufferView>;
  65364. /**
  65365. * The pixel array for the up face.
  65366. * This is stored in format, left to right, up to down format.
  65367. */
  65368. up: Nullable<ArrayBufferView>;
  65369. /**
  65370. * The pixel array for the down face.
  65371. * This is stored in format, left to right, up to down format.
  65372. */
  65373. down: Nullable<ArrayBufferView>;
  65374. /**
  65375. * The size of the cubemap stored.
  65376. *
  65377. * Each faces will be size * size pixels.
  65378. */
  65379. size: number;
  65380. /**
  65381. * The format of the texture.
  65382. *
  65383. * RGBA, RGB.
  65384. */
  65385. format: number;
  65386. /**
  65387. * The type of the texture data.
  65388. *
  65389. * UNSIGNED_INT, FLOAT.
  65390. */
  65391. type: number;
  65392. /**
  65393. * Specifies whether the texture is in gamma space.
  65394. */
  65395. gammaSpace: boolean;
  65396. }
  65397. /**
  65398. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65399. */
  65400. export class PanoramaToCubeMapTools {
  65401. private static FACE_FRONT;
  65402. private static FACE_BACK;
  65403. private static FACE_RIGHT;
  65404. private static FACE_LEFT;
  65405. private static FACE_DOWN;
  65406. private static FACE_UP;
  65407. /**
  65408. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65409. *
  65410. * @param float32Array The source data.
  65411. * @param inputWidth The width of the input panorama.
  65412. * @param inputHeight The height of the input panorama.
  65413. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65414. * @return The cubemap data
  65415. */
  65416. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65417. private static CreateCubemapTexture;
  65418. private static CalcProjectionSpherical;
  65419. }
  65420. }
  65421. declare module BABYLON {
  65422. /**
  65423. * Helper class dealing with the extraction of spherical polynomial dataArray
  65424. * from a cube map.
  65425. */
  65426. export class CubeMapToSphericalPolynomialTools {
  65427. private static FileFaces;
  65428. /**
  65429. * Converts a texture to the according Spherical Polynomial data.
  65430. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65431. *
  65432. * @param texture The texture to extract the information from.
  65433. * @return The Spherical Polynomial data.
  65434. */
  65435. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65436. /**
  65437. * Converts a cubemap to the according Spherical Polynomial data.
  65438. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65439. *
  65440. * @param cubeInfo The Cube map to extract the information from.
  65441. * @return The Spherical Polynomial data.
  65442. */
  65443. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65444. }
  65445. }
  65446. declare module BABYLON {
  65447. /**
  65448. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65449. * during the life time of the application.
  65450. */
  65451. export class EngineStore {
  65452. /** Gets the list of created engines */
  65453. static Instances: Engine[];
  65454. /**
  65455. * Gets the latest created engine
  65456. */
  65457. static readonly LastCreatedEngine: Nullable<Engine>;
  65458. /**
  65459. * Gets the latest created scene
  65460. */
  65461. static readonly LastCreatedScene: Nullable<Scene>;
  65462. }
  65463. }
  65464. declare module BABYLON {
  65465. /**
  65466. * Define options used to create a render target texture
  65467. */
  65468. export class RenderTargetCreationOptions {
  65469. /**
  65470. * Specifies is mipmaps must be generated
  65471. */
  65472. generateMipMaps?: boolean;
  65473. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65474. generateDepthBuffer?: boolean;
  65475. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65476. generateStencilBuffer?: boolean;
  65477. /** Defines texture type (int by default) */
  65478. type?: number;
  65479. /** Defines sampling mode (trilinear by default) */
  65480. samplingMode?: number;
  65481. /** Defines format (RGBA by default) */
  65482. format?: number;
  65483. }
  65484. }
  65485. declare module BABYLON {
  65486. /**
  65487. * @hidden
  65488. **/
  65489. export class _AlphaState {
  65490. private _isAlphaBlendDirty;
  65491. private _isBlendFunctionParametersDirty;
  65492. private _isBlendEquationParametersDirty;
  65493. private _isBlendConstantsDirty;
  65494. private _alphaBlend;
  65495. private _blendFunctionParameters;
  65496. private _blendEquationParameters;
  65497. private _blendConstants;
  65498. /**
  65499. * Initializes the state.
  65500. */
  65501. constructor();
  65502. readonly isDirty: boolean;
  65503. alphaBlend: boolean;
  65504. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65505. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65506. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65507. reset(): void;
  65508. apply(gl: WebGLRenderingContext): void;
  65509. }
  65510. }
  65511. declare module BABYLON {
  65512. /**
  65513. * @hidden
  65514. **/
  65515. export class _DepthCullingState {
  65516. private _isDepthTestDirty;
  65517. private _isDepthMaskDirty;
  65518. private _isDepthFuncDirty;
  65519. private _isCullFaceDirty;
  65520. private _isCullDirty;
  65521. private _isZOffsetDirty;
  65522. private _isFrontFaceDirty;
  65523. private _depthTest;
  65524. private _depthMask;
  65525. private _depthFunc;
  65526. private _cull;
  65527. private _cullFace;
  65528. private _zOffset;
  65529. private _frontFace;
  65530. /**
  65531. * Initializes the state.
  65532. */
  65533. constructor();
  65534. readonly isDirty: boolean;
  65535. zOffset: number;
  65536. cullFace: Nullable<number>;
  65537. cull: Nullable<boolean>;
  65538. depthFunc: Nullable<number>;
  65539. depthMask: boolean;
  65540. depthTest: boolean;
  65541. frontFace: Nullable<number>;
  65542. reset(): void;
  65543. apply(gl: WebGLRenderingContext): void;
  65544. }
  65545. }
  65546. declare module BABYLON {
  65547. /**
  65548. * @hidden
  65549. **/
  65550. export class _StencilState {
  65551. /** 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 */
  65552. static readonly ALWAYS: number;
  65553. /** Passed to stencilOperation to specify that stencil value must be kept */
  65554. static readonly KEEP: number;
  65555. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65556. static readonly REPLACE: number;
  65557. private _isStencilTestDirty;
  65558. private _isStencilMaskDirty;
  65559. private _isStencilFuncDirty;
  65560. private _isStencilOpDirty;
  65561. private _stencilTest;
  65562. private _stencilMask;
  65563. private _stencilFunc;
  65564. private _stencilFuncRef;
  65565. private _stencilFuncMask;
  65566. private _stencilOpStencilFail;
  65567. private _stencilOpDepthFail;
  65568. private _stencilOpStencilDepthPass;
  65569. readonly isDirty: boolean;
  65570. stencilFunc: number;
  65571. stencilFuncRef: number;
  65572. stencilFuncMask: number;
  65573. stencilOpStencilFail: number;
  65574. stencilOpDepthFail: number;
  65575. stencilOpStencilDepthPass: number;
  65576. stencilMask: number;
  65577. stencilTest: boolean;
  65578. constructor();
  65579. reset(): void;
  65580. apply(gl: WebGLRenderingContext): void;
  65581. }
  65582. }
  65583. declare module BABYLON {
  65584. /**
  65585. * @hidden
  65586. **/
  65587. export class _TimeToken {
  65588. _startTimeQuery: Nullable<WebGLQuery>;
  65589. _endTimeQuery: Nullable<WebGLQuery>;
  65590. _timeElapsedQuery: Nullable<WebGLQuery>;
  65591. _timeElapsedQueryEnded: boolean;
  65592. }
  65593. }
  65594. declare module BABYLON {
  65595. /**
  65596. * Class used to store data associated with WebGL texture data for the engine
  65597. * This class should not be used directly
  65598. */
  65599. export class InternalTexture {
  65600. /** hidden */
  65601. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65602. /**
  65603. * The source of the texture data is unknown
  65604. */
  65605. static DATASOURCE_UNKNOWN: number;
  65606. /**
  65607. * Texture data comes from an URL
  65608. */
  65609. static DATASOURCE_URL: number;
  65610. /**
  65611. * Texture data is only used for temporary storage
  65612. */
  65613. static DATASOURCE_TEMP: number;
  65614. /**
  65615. * Texture data comes from raw data (ArrayBuffer)
  65616. */
  65617. static DATASOURCE_RAW: number;
  65618. /**
  65619. * Texture content is dynamic (video or dynamic texture)
  65620. */
  65621. static DATASOURCE_DYNAMIC: number;
  65622. /**
  65623. * Texture content is generated by rendering to it
  65624. */
  65625. static DATASOURCE_RENDERTARGET: number;
  65626. /**
  65627. * Texture content is part of a multi render target process
  65628. */
  65629. static DATASOURCE_MULTIRENDERTARGET: number;
  65630. /**
  65631. * Texture data comes from a cube data file
  65632. */
  65633. static DATASOURCE_CUBE: number;
  65634. /**
  65635. * Texture data comes from a raw cube data
  65636. */
  65637. static DATASOURCE_CUBERAW: number;
  65638. /**
  65639. * Texture data come from a prefiltered cube data file
  65640. */
  65641. static DATASOURCE_CUBEPREFILTERED: number;
  65642. /**
  65643. * Texture content is raw 3D data
  65644. */
  65645. static DATASOURCE_RAW3D: number;
  65646. /**
  65647. * Texture content is a depth texture
  65648. */
  65649. static DATASOURCE_DEPTHTEXTURE: number;
  65650. /**
  65651. * Texture data comes from a raw cube data encoded with RGBD
  65652. */
  65653. static DATASOURCE_CUBERAW_RGBD: number;
  65654. /**
  65655. * Defines if the texture is ready
  65656. */
  65657. isReady: boolean;
  65658. /**
  65659. * Defines if the texture is a cube texture
  65660. */
  65661. isCube: boolean;
  65662. /**
  65663. * Defines if the texture contains 3D data
  65664. */
  65665. is3D: boolean;
  65666. /**
  65667. * Defines if the texture contains multiview data
  65668. */
  65669. isMultiview: boolean;
  65670. /**
  65671. * Gets the URL used to load this texture
  65672. */
  65673. url: string;
  65674. /**
  65675. * Gets the sampling mode of the texture
  65676. */
  65677. samplingMode: number;
  65678. /**
  65679. * Gets a boolean indicating if the texture needs mipmaps generation
  65680. */
  65681. generateMipMaps: boolean;
  65682. /**
  65683. * Gets the number of samples used by the texture (WebGL2+ only)
  65684. */
  65685. samples: number;
  65686. /**
  65687. * Gets the type of the texture (int, float...)
  65688. */
  65689. type: number;
  65690. /**
  65691. * Gets the format of the texture (RGB, RGBA...)
  65692. */
  65693. format: number;
  65694. /**
  65695. * Observable called when the texture is loaded
  65696. */
  65697. onLoadedObservable: Observable<InternalTexture>;
  65698. /**
  65699. * Gets the width of the texture
  65700. */
  65701. width: number;
  65702. /**
  65703. * Gets the height of the texture
  65704. */
  65705. height: number;
  65706. /**
  65707. * Gets the depth of the texture
  65708. */
  65709. depth: number;
  65710. /**
  65711. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65712. */
  65713. baseWidth: number;
  65714. /**
  65715. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65716. */
  65717. baseHeight: number;
  65718. /**
  65719. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65720. */
  65721. baseDepth: number;
  65722. /**
  65723. * Gets a boolean indicating if the texture is inverted on Y axis
  65724. */
  65725. invertY: boolean;
  65726. /** @hidden */
  65727. _invertVScale: boolean;
  65728. /** @hidden */
  65729. _associatedChannel: number;
  65730. /** @hidden */
  65731. _dataSource: number;
  65732. /** @hidden */
  65733. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65734. /** @hidden */
  65735. _bufferView: Nullable<ArrayBufferView>;
  65736. /** @hidden */
  65737. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65738. /** @hidden */
  65739. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65740. /** @hidden */
  65741. _size: number;
  65742. /** @hidden */
  65743. _extension: string;
  65744. /** @hidden */
  65745. _files: Nullable<string[]>;
  65746. /** @hidden */
  65747. _workingCanvas: Nullable<HTMLCanvasElement>;
  65748. /** @hidden */
  65749. _workingContext: Nullable<CanvasRenderingContext2D>;
  65750. /** @hidden */
  65751. _framebuffer: Nullable<WebGLFramebuffer>;
  65752. /** @hidden */
  65753. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65754. /** @hidden */
  65755. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65756. /** @hidden */
  65757. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65758. /** @hidden */
  65759. _attachments: Nullable<number[]>;
  65760. /** @hidden */
  65761. _cachedCoordinatesMode: Nullable<number>;
  65762. /** @hidden */
  65763. _cachedWrapU: Nullable<number>;
  65764. /** @hidden */
  65765. _cachedWrapV: Nullable<number>;
  65766. /** @hidden */
  65767. _cachedWrapR: Nullable<number>;
  65768. /** @hidden */
  65769. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65770. /** @hidden */
  65771. _isDisabled: boolean;
  65772. /** @hidden */
  65773. _compression: Nullable<string>;
  65774. /** @hidden */
  65775. _generateStencilBuffer: boolean;
  65776. /** @hidden */
  65777. _generateDepthBuffer: boolean;
  65778. /** @hidden */
  65779. _comparisonFunction: number;
  65780. /** @hidden */
  65781. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65782. /** @hidden */
  65783. _lodGenerationScale: number;
  65784. /** @hidden */
  65785. _lodGenerationOffset: number;
  65786. /** @hidden */
  65787. _colorTextureArray: Nullable<WebGLTexture>;
  65788. /** @hidden */
  65789. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65790. /** @hidden */
  65791. _lodTextureHigh: Nullable<BaseTexture>;
  65792. /** @hidden */
  65793. _lodTextureMid: Nullable<BaseTexture>;
  65794. /** @hidden */
  65795. _lodTextureLow: Nullable<BaseTexture>;
  65796. /** @hidden */
  65797. _isRGBD: boolean;
  65798. /** @hidden */
  65799. _webGLTexture: Nullable<WebGLTexture>;
  65800. /** @hidden */
  65801. _references: number;
  65802. private _engine;
  65803. /**
  65804. * Gets the Engine the texture belongs to.
  65805. * @returns The babylon engine
  65806. */
  65807. getEngine(): Engine;
  65808. /**
  65809. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65810. */
  65811. readonly dataSource: number;
  65812. /**
  65813. * Creates a new InternalTexture
  65814. * @param engine defines the engine to use
  65815. * @param dataSource defines the type of data that will be used
  65816. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65817. */
  65818. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65819. /**
  65820. * Increments the number of references (ie. the number of Texture that point to it)
  65821. */
  65822. incrementReferences(): void;
  65823. /**
  65824. * Change the size of the texture (not the size of the content)
  65825. * @param width defines the new width
  65826. * @param height defines the new height
  65827. * @param depth defines the new depth (1 by default)
  65828. */
  65829. updateSize(width: int, height: int, depth?: int): void;
  65830. /** @hidden */
  65831. _rebuild(): void;
  65832. /** @hidden */
  65833. _swapAndDie(target: InternalTexture): void;
  65834. /**
  65835. * Dispose the current allocated resources
  65836. */
  65837. dispose(): void;
  65838. }
  65839. }
  65840. declare module BABYLON {
  65841. /**
  65842. * This represents the main contract an easing function should follow.
  65843. * Easing functions are used throughout the animation system.
  65844. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65845. */
  65846. export interface IEasingFunction {
  65847. /**
  65848. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65849. * of the easing function.
  65850. * The link below provides some of the most common examples of easing functions.
  65851. * @see https://easings.net/
  65852. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65853. * @returns the corresponding value on the curve defined by the easing function
  65854. */
  65855. ease(gradient: number): number;
  65856. }
  65857. /**
  65858. * Base class used for every default easing function.
  65859. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65860. */
  65861. export class EasingFunction implements IEasingFunction {
  65862. /**
  65863. * Interpolation follows the mathematical formula associated with the easing function.
  65864. */
  65865. static readonly EASINGMODE_EASEIN: number;
  65866. /**
  65867. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  65868. */
  65869. static readonly EASINGMODE_EASEOUT: number;
  65870. /**
  65871. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  65872. */
  65873. static readonly EASINGMODE_EASEINOUT: number;
  65874. private _easingMode;
  65875. /**
  65876. * Sets the easing mode of the current function.
  65877. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  65878. */
  65879. setEasingMode(easingMode: number): void;
  65880. /**
  65881. * Gets the current easing mode.
  65882. * @returns the easing mode
  65883. */
  65884. getEasingMode(): number;
  65885. /**
  65886. * @hidden
  65887. */
  65888. easeInCore(gradient: number): number;
  65889. /**
  65890. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65891. * of the easing function.
  65892. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65893. * @returns the corresponding value on the curve defined by the easing function
  65894. */
  65895. ease(gradient: number): number;
  65896. }
  65897. /**
  65898. * Easing function with a circle shape (see link below).
  65899. * @see https://easings.net/#easeInCirc
  65900. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65901. */
  65902. export class CircleEase extends EasingFunction implements IEasingFunction {
  65903. /** @hidden */
  65904. easeInCore(gradient: number): number;
  65905. }
  65906. /**
  65907. * Easing function with a ease back shape (see link below).
  65908. * @see https://easings.net/#easeInBack
  65909. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65910. */
  65911. export class BackEase extends EasingFunction implements IEasingFunction {
  65912. /** Defines the amplitude of the function */
  65913. amplitude: number;
  65914. /**
  65915. * Instantiates a back ease easing
  65916. * @see https://easings.net/#easeInBack
  65917. * @param amplitude Defines the amplitude of the function
  65918. */
  65919. constructor(
  65920. /** Defines the amplitude of the function */
  65921. amplitude?: number);
  65922. /** @hidden */
  65923. easeInCore(gradient: number): number;
  65924. }
  65925. /**
  65926. * Easing function with a bouncing shape (see link below).
  65927. * @see https://easings.net/#easeInBounce
  65928. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65929. */
  65930. export class BounceEase extends EasingFunction implements IEasingFunction {
  65931. /** Defines the number of bounces */
  65932. bounces: number;
  65933. /** Defines the amplitude of the bounce */
  65934. bounciness: number;
  65935. /**
  65936. * Instantiates a bounce easing
  65937. * @see https://easings.net/#easeInBounce
  65938. * @param bounces Defines the number of bounces
  65939. * @param bounciness Defines the amplitude of the bounce
  65940. */
  65941. constructor(
  65942. /** Defines the number of bounces */
  65943. bounces?: number,
  65944. /** Defines the amplitude of the bounce */
  65945. bounciness?: number);
  65946. /** @hidden */
  65947. easeInCore(gradient: number): number;
  65948. }
  65949. /**
  65950. * Easing function with a power of 3 shape (see link below).
  65951. * @see https://easings.net/#easeInCubic
  65952. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65953. */
  65954. export class CubicEase extends EasingFunction implements IEasingFunction {
  65955. /** @hidden */
  65956. easeInCore(gradient: number): number;
  65957. }
  65958. /**
  65959. * Easing function with an elastic shape (see link below).
  65960. * @see https://easings.net/#easeInElastic
  65961. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65962. */
  65963. export class ElasticEase extends EasingFunction implements IEasingFunction {
  65964. /** Defines the number of oscillations*/
  65965. oscillations: number;
  65966. /** Defines the amplitude of the oscillations*/
  65967. springiness: number;
  65968. /**
  65969. * Instantiates an elastic easing function
  65970. * @see https://easings.net/#easeInElastic
  65971. * @param oscillations Defines the number of oscillations
  65972. * @param springiness Defines the amplitude of the oscillations
  65973. */
  65974. constructor(
  65975. /** Defines the number of oscillations*/
  65976. oscillations?: number,
  65977. /** Defines the amplitude of the oscillations*/
  65978. springiness?: number);
  65979. /** @hidden */
  65980. easeInCore(gradient: number): number;
  65981. }
  65982. /**
  65983. * Easing function with an exponential shape (see link below).
  65984. * @see https://easings.net/#easeInExpo
  65985. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65986. */
  65987. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  65988. /** Defines the exponent of the function */
  65989. exponent: number;
  65990. /**
  65991. * Instantiates an exponential easing function
  65992. * @see https://easings.net/#easeInExpo
  65993. * @param exponent Defines the exponent of the function
  65994. */
  65995. constructor(
  65996. /** Defines the exponent of the function */
  65997. exponent?: number);
  65998. /** @hidden */
  65999. easeInCore(gradient: number): number;
  66000. }
  66001. /**
  66002. * Easing function with a power shape (see link below).
  66003. * @see https://easings.net/#easeInQuad
  66004. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66005. */
  66006. export class PowerEase extends EasingFunction implements IEasingFunction {
  66007. /** Defines the power of the function */
  66008. power: number;
  66009. /**
  66010. * Instantiates an power base easing function
  66011. * @see https://easings.net/#easeInQuad
  66012. * @param power Defines the power of the function
  66013. */
  66014. constructor(
  66015. /** Defines the power of the function */
  66016. power?: number);
  66017. /** @hidden */
  66018. easeInCore(gradient: number): number;
  66019. }
  66020. /**
  66021. * Easing function with a power of 2 shape (see link below).
  66022. * @see https://easings.net/#easeInQuad
  66023. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66024. */
  66025. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66026. /** @hidden */
  66027. easeInCore(gradient: number): number;
  66028. }
  66029. /**
  66030. * Easing function with a power of 4 shape (see link below).
  66031. * @see https://easings.net/#easeInQuart
  66032. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66033. */
  66034. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66035. /** @hidden */
  66036. easeInCore(gradient: number): number;
  66037. }
  66038. /**
  66039. * Easing function with a power of 5 shape (see link below).
  66040. * @see https://easings.net/#easeInQuint
  66041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66042. */
  66043. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66044. /** @hidden */
  66045. easeInCore(gradient: number): number;
  66046. }
  66047. /**
  66048. * Easing function with a sin shape (see link below).
  66049. * @see https://easings.net/#easeInSine
  66050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66051. */
  66052. export class SineEase extends EasingFunction implements IEasingFunction {
  66053. /** @hidden */
  66054. easeInCore(gradient: number): number;
  66055. }
  66056. /**
  66057. * Easing function with a bezier shape (see link below).
  66058. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66059. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66060. */
  66061. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66062. /** Defines the x component of the start tangent in the bezier curve */
  66063. x1: number;
  66064. /** Defines the y component of the start tangent in the bezier curve */
  66065. y1: number;
  66066. /** Defines the x component of the end tangent in the bezier curve */
  66067. x2: number;
  66068. /** Defines the y component of the end tangent in the bezier curve */
  66069. y2: number;
  66070. /**
  66071. * Instantiates a bezier function
  66072. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66073. * @param x1 Defines the x component of the start tangent in the bezier curve
  66074. * @param y1 Defines the y component of the start tangent in the bezier curve
  66075. * @param x2 Defines the x component of the end tangent in the bezier curve
  66076. * @param y2 Defines the y component of the end tangent in the bezier curve
  66077. */
  66078. constructor(
  66079. /** Defines the x component of the start tangent in the bezier curve */
  66080. x1?: number,
  66081. /** Defines the y component of the start tangent in the bezier curve */
  66082. y1?: number,
  66083. /** Defines the x component of the end tangent in the bezier curve */
  66084. x2?: number,
  66085. /** Defines the y component of the end tangent in the bezier curve */
  66086. y2?: number);
  66087. /** @hidden */
  66088. easeInCore(gradient: number): number;
  66089. }
  66090. }
  66091. declare module BABYLON {
  66092. /**
  66093. * Defines an interface which represents an animation key frame
  66094. */
  66095. export interface IAnimationKey {
  66096. /**
  66097. * Frame of the key frame
  66098. */
  66099. frame: number;
  66100. /**
  66101. * Value at the specifies key frame
  66102. */
  66103. value: any;
  66104. /**
  66105. * The input tangent for the cubic hermite spline
  66106. */
  66107. inTangent?: any;
  66108. /**
  66109. * The output tangent for the cubic hermite spline
  66110. */
  66111. outTangent?: any;
  66112. /**
  66113. * The animation interpolation type
  66114. */
  66115. interpolation?: AnimationKeyInterpolation;
  66116. }
  66117. /**
  66118. * Enum for the animation key frame interpolation type
  66119. */
  66120. export enum AnimationKeyInterpolation {
  66121. /**
  66122. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66123. */
  66124. STEP = 1
  66125. }
  66126. }
  66127. declare module BABYLON {
  66128. /**
  66129. * Represents the range of an animation
  66130. */
  66131. export class AnimationRange {
  66132. /**The name of the animation range**/
  66133. name: string;
  66134. /**The starting frame of the animation */
  66135. from: number;
  66136. /**The ending frame of the animation*/
  66137. to: number;
  66138. /**
  66139. * Initializes the range of an animation
  66140. * @param name The name of the animation range
  66141. * @param from The starting frame of the animation
  66142. * @param to The ending frame of the animation
  66143. */
  66144. constructor(
  66145. /**The name of the animation range**/
  66146. name: string,
  66147. /**The starting frame of the animation */
  66148. from: number,
  66149. /**The ending frame of the animation*/
  66150. to: number);
  66151. /**
  66152. * Makes a copy of the animation range
  66153. * @returns A copy of the animation range
  66154. */
  66155. clone(): AnimationRange;
  66156. }
  66157. }
  66158. declare module BABYLON {
  66159. /**
  66160. * Composed of a frame, and an action function
  66161. */
  66162. export class AnimationEvent {
  66163. /** The frame for which the event is triggered **/
  66164. frame: number;
  66165. /** The event to perform when triggered **/
  66166. action: (currentFrame: number) => void;
  66167. /** Specifies if the event should be triggered only once**/
  66168. onlyOnce?: boolean | undefined;
  66169. /**
  66170. * Specifies if the animation event is done
  66171. */
  66172. isDone: boolean;
  66173. /**
  66174. * Initializes the animation event
  66175. * @param frame The frame for which the event is triggered
  66176. * @param action The event to perform when triggered
  66177. * @param onlyOnce Specifies if the event should be triggered only once
  66178. */
  66179. constructor(
  66180. /** The frame for which the event is triggered **/
  66181. frame: number,
  66182. /** The event to perform when triggered **/
  66183. action: (currentFrame: number) => void,
  66184. /** Specifies if the event should be triggered only once**/
  66185. onlyOnce?: boolean | undefined);
  66186. /** @hidden */
  66187. _clone(): AnimationEvent;
  66188. }
  66189. }
  66190. declare module BABYLON {
  66191. /**
  66192. * Interface used to define a behavior
  66193. */
  66194. export interface Behavior<T> {
  66195. /** gets or sets behavior's name */
  66196. name: string;
  66197. /**
  66198. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66199. */
  66200. init(): void;
  66201. /**
  66202. * Called when the behavior is attached to a target
  66203. * @param target defines the target where the behavior is attached to
  66204. */
  66205. attach(target: T): void;
  66206. /**
  66207. * Called when the behavior is detached from its target
  66208. */
  66209. detach(): void;
  66210. }
  66211. /**
  66212. * Interface implemented by classes supporting behaviors
  66213. */
  66214. export interface IBehaviorAware<T> {
  66215. /**
  66216. * Attach a behavior
  66217. * @param behavior defines the behavior to attach
  66218. * @returns the current host
  66219. */
  66220. addBehavior(behavior: Behavior<T>): T;
  66221. /**
  66222. * Remove a behavior from the current object
  66223. * @param behavior defines the behavior to detach
  66224. * @returns the current host
  66225. */
  66226. removeBehavior(behavior: Behavior<T>): T;
  66227. /**
  66228. * Gets a behavior using its name to search
  66229. * @param name defines the name to search
  66230. * @returns the behavior or null if not found
  66231. */
  66232. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66233. }
  66234. }
  66235. declare module BABYLON {
  66236. /**
  66237. * @hidden
  66238. */
  66239. export class IntersectionInfo {
  66240. bu: Nullable<number>;
  66241. bv: Nullable<number>;
  66242. distance: number;
  66243. faceId: number;
  66244. subMeshId: number;
  66245. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66246. }
  66247. }
  66248. declare module BABYLON {
  66249. /**
  66250. * Class used to store bounding sphere information
  66251. */
  66252. export class BoundingSphere {
  66253. /**
  66254. * Gets the center of the bounding sphere in local space
  66255. */
  66256. readonly center: Vector3;
  66257. /**
  66258. * Radius of the bounding sphere in local space
  66259. */
  66260. radius: number;
  66261. /**
  66262. * Gets the center of the bounding sphere in world space
  66263. */
  66264. readonly centerWorld: Vector3;
  66265. /**
  66266. * Radius of the bounding sphere in world space
  66267. */
  66268. radiusWorld: number;
  66269. /**
  66270. * Gets the minimum vector in local space
  66271. */
  66272. readonly minimum: Vector3;
  66273. /**
  66274. * Gets the maximum vector in local space
  66275. */
  66276. readonly maximum: Vector3;
  66277. private _worldMatrix;
  66278. private static readonly TmpVector3;
  66279. /**
  66280. * Creates a new bounding sphere
  66281. * @param min defines the minimum vector (in local space)
  66282. * @param max defines the maximum vector (in local space)
  66283. * @param worldMatrix defines the new world matrix
  66284. */
  66285. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66286. /**
  66287. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66288. * @param min defines the new minimum vector (in local space)
  66289. * @param max defines the new maximum vector (in local space)
  66290. * @param worldMatrix defines the new world matrix
  66291. */
  66292. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66293. /**
  66294. * Scale the current bounding sphere by applying a scale factor
  66295. * @param factor defines the scale factor to apply
  66296. * @returns the current bounding box
  66297. */
  66298. scale(factor: number): BoundingSphere;
  66299. /**
  66300. * Gets the world matrix of the bounding box
  66301. * @returns a matrix
  66302. */
  66303. getWorldMatrix(): DeepImmutable<Matrix>;
  66304. /** @hidden */
  66305. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66306. /**
  66307. * Tests if the bounding sphere is intersecting the frustum planes
  66308. * @param frustumPlanes defines the frustum planes to test
  66309. * @returns true if there is an intersection
  66310. */
  66311. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66312. /**
  66313. * Tests if the bounding sphere center is in between the frustum planes.
  66314. * Used for optimistic fast inclusion.
  66315. * @param frustumPlanes defines the frustum planes to test
  66316. * @returns true if the sphere center is in between the frustum planes
  66317. */
  66318. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66319. /**
  66320. * Tests if a point is inside the bounding sphere
  66321. * @param point defines the point to test
  66322. * @returns true if the point is inside the bounding sphere
  66323. */
  66324. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66325. /**
  66326. * Checks if two sphere intersct
  66327. * @param sphere0 sphere 0
  66328. * @param sphere1 sphere 1
  66329. * @returns true if the speres intersect
  66330. */
  66331. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66332. }
  66333. }
  66334. declare module BABYLON {
  66335. /**
  66336. * Class used to store bounding box information
  66337. */
  66338. export class BoundingBox implements ICullable {
  66339. /**
  66340. * Gets the 8 vectors representing the bounding box in local space
  66341. */
  66342. readonly vectors: Vector3[];
  66343. /**
  66344. * Gets the center of the bounding box in local space
  66345. */
  66346. readonly center: Vector3;
  66347. /**
  66348. * Gets the center of the bounding box in world space
  66349. */
  66350. readonly centerWorld: Vector3;
  66351. /**
  66352. * Gets the extend size in local space
  66353. */
  66354. readonly extendSize: Vector3;
  66355. /**
  66356. * Gets the extend size in world space
  66357. */
  66358. readonly extendSizeWorld: Vector3;
  66359. /**
  66360. * Gets the OBB (object bounding box) directions
  66361. */
  66362. readonly directions: Vector3[];
  66363. /**
  66364. * Gets the 8 vectors representing the bounding box in world space
  66365. */
  66366. readonly vectorsWorld: Vector3[];
  66367. /**
  66368. * Gets the minimum vector in world space
  66369. */
  66370. readonly minimumWorld: Vector3;
  66371. /**
  66372. * Gets the maximum vector in world space
  66373. */
  66374. readonly maximumWorld: Vector3;
  66375. /**
  66376. * Gets the minimum vector in local space
  66377. */
  66378. readonly minimum: Vector3;
  66379. /**
  66380. * Gets the maximum vector in local space
  66381. */
  66382. readonly maximum: Vector3;
  66383. private _worldMatrix;
  66384. private static readonly TmpVector3;
  66385. /**
  66386. * @hidden
  66387. */
  66388. _tag: number;
  66389. /**
  66390. * Creates a new bounding box
  66391. * @param min defines the minimum vector (in local space)
  66392. * @param max defines the maximum vector (in local space)
  66393. * @param worldMatrix defines the new world matrix
  66394. */
  66395. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66396. /**
  66397. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66398. * @param min defines the new minimum vector (in local space)
  66399. * @param max defines the new maximum vector (in local space)
  66400. * @param worldMatrix defines the new world matrix
  66401. */
  66402. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66403. /**
  66404. * Scale the current bounding box by applying a scale factor
  66405. * @param factor defines the scale factor to apply
  66406. * @returns the current bounding box
  66407. */
  66408. scale(factor: number): BoundingBox;
  66409. /**
  66410. * Gets the world matrix of the bounding box
  66411. * @returns a matrix
  66412. */
  66413. getWorldMatrix(): DeepImmutable<Matrix>;
  66414. /** @hidden */
  66415. _update(world: DeepImmutable<Matrix>): void;
  66416. /**
  66417. * Tests if the bounding box is intersecting the frustum planes
  66418. * @param frustumPlanes defines the frustum planes to test
  66419. * @returns true if there is an intersection
  66420. */
  66421. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66422. /**
  66423. * Tests if the bounding box is entirely inside the frustum planes
  66424. * @param frustumPlanes defines the frustum planes to test
  66425. * @returns true if there is an inclusion
  66426. */
  66427. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66428. /**
  66429. * Tests if a point is inside the bounding box
  66430. * @param point defines the point to test
  66431. * @returns true if the point is inside the bounding box
  66432. */
  66433. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66434. /**
  66435. * Tests if the bounding box intersects with a bounding sphere
  66436. * @param sphere defines the sphere to test
  66437. * @returns true if there is an intersection
  66438. */
  66439. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66440. /**
  66441. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66442. * @param min defines the min vector to use
  66443. * @param max defines the max vector to use
  66444. * @returns true if there is an intersection
  66445. */
  66446. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66447. /**
  66448. * Tests if two bounding boxes are intersections
  66449. * @param box0 defines the first box to test
  66450. * @param box1 defines the second box to test
  66451. * @returns true if there is an intersection
  66452. */
  66453. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66454. /**
  66455. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66456. * @param minPoint defines the minimum vector of the bounding box
  66457. * @param maxPoint defines the maximum vector of the bounding box
  66458. * @param sphereCenter defines the sphere center
  66459. * @param sphereRadius defines the sphere radius
  66460. * @returns true if there is an intersection
  66461. */
  66462. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66463. /**
  66464. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66465. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66466. * @param frustumPlanes defines the frustum planes to test
  66467. * @return true if there is an inclusion
  66468. */
  66469. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66470. /**
  66471. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66472. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66473. * @param frustumPlanes defines the frustum planes to test
  66474. * @return true if there is an intersection
  66475. */
  66476. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66477. }
  66478. }
  66479. declare module BABYLON {
  66480. /** @hidden */
  66481. export class Collider {
  66482. /** Define if a collision was found */
  66483. collisionFound: boolean;
  66484. /**
  66485. * Define last intersection point in local space
  66486. */
  66487. intersectionPoint: Vector3;
  66488. /**
  66489. * Define last collided mesh
  66490. */
  66491. collidedMesh: Nullable<AbstractMesh>;
  66492. private _collisionPoint;
  66493. private _planeIntersectionPoint;
  66494. private _tempVector;
  66495. private _tempVector2;
  66496. private _tempVector3;
  66497. private _tempVector4;
  66498. private _edge;
  66499. private _baseToVertex;
  66500. private _destinationPoint;
  66501. private _slidePlaneNormal;
  66502. private _displacementVector;
  66503. /** @hidden */
  66504. _radius: Vector3;
  66505. /** @hidden */
  66506. _retry: number;
  66507. private _velocity;
  66508. private _basePoint;
  66509. private _epsilon;
  66510. /** @hidden */
  66511. _velocityWorldLength: number;
  66512. /** @hidden */
  66513. _basePointWorld: Vector3;
  66514. private _velocityWorld;
  66515. private _normalizedVelocity;
  66516. /** @hidden */
  66517. _initialVelocity: Vector3;
  66518. /** @hidden */
  66519. _initialPosition: Vector3;
  66520. private _nearestDistance;
  66521. private _collisionMask;
  66522. collisionMask: number;
  66523. /**
  66524. * Gets the plane normal used to compute the sliding response (in local space)
  66525. */
  66526. readonly slidePlaneNormal: Vector3;
  66527. /** @hidden */
  66528. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66529. /** @hidden */
  66530. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66531. /** @hidden */
  66532. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66533. /** @hidden */
  66534. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66535. /** @hidden */
  66536. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66537. /** @hidden */
  66538. _getResponse(pos: Vector3, vel: Vector3): void;
  66539. }
  66540. }
  66541. declare module BABYLON {
  66542. /**
  66543. * Interface for cullable objects
  66544. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66545. */
  66546. export interface ICullable {
  66547. /**
  66548. * Checks if the object or part of the object is in the frustum
  66549. * @param frustumPlanes Camera near/planes
  66550. * @returns true if the object is in frustum otherwise false
  66551. */
  66552. isInFrustum(frustumPlanes: Plane[]): boolean;
  66553. /**
  66554. * Checks if a cullable object (mesh...) is in the camera frustum
  66555. * Unlike isInFrustum this cheks the full bounding box
  66556. * @param frustumPlanes Camera near/planes
  66557. * @returns true if the object is in frustum otherwise false
  66558. */
  66559. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66560. }
  66561. /**
  66562. * Info for a bounding data of a mesh
  66563. */
  66564. export class BoundingInfo implements ICullable {
  66565. /**
  66566. * Bounding box for the mesh
  66567. */
  66568. readonly boundingBox: BoundingBox;
  66569. /**
  66570. * Bounding sphere for the mesh
  66571. */
  66572. readonly boundingSphere: BoundingSphere;
  66573. private _isLocked;
  66574. private static readonly TmpVector3;
  66575. /**
  66576. * Constructs bounding info
  66577. * @param minimum min vector of the bounding box/sphere
  66578. * @param maximum max vector of the bounding box/sphere
  66579. * @param worldMatrix defines the new world matrix
  66580. */
  66581. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66582. /**
  66583. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66584. * @param min defines the new minimum vector (in local space)
  66585. * @param max defines the new maximum vector (in local space)
  66586. * @param worldMatrix defines the new world matrix
  66587. */
  66588. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66589. /**
  66590. * min vector of the bounding box/sphere
  66591. */
  66592. readonly minimum: Vector3;
  66593. /**
  66594. * max vector of the bounding box/sphere
  66595. */
  66596. readonly maximum: Vector3;
  66597. /**
  66598. * If the info is locked and won't be updated to avoid perf overhead
  66599. */
  66600. isLocked: boolean;
  66601. /**
  66602. * Updates the bounding sphere and box
  66603. * @param world world matrix to be used to update
  66604. */
  66605. update(world: DeepImmutable<Matrix>): void;
  66606. /**
  66607. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66608. * @param center New center of the bounding info
  66609. * @param extend New extend of the bounding info
  66610. * @returns the current bounding info
  66611. */
  66612. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66613. /**
  66614. * Scale the current bounding info by applying a scale factor
  66615. * @param factor defines the scale factor to apply
  66616. * @returns the current bounding info
  66617. */
  66618. scale(factor: number): BoundingInfo;
  66619. /**
  66620. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66621. * @param frustumPlanes defines the frustum to test
  66622. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66623. * @returns true if the bounding info is in the frustum planes
  66624. */
  66625. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66626. /**
  66627. * Gets the world distance between the min and max points of the bounding box
  66628. */
  66629. readonly diagonalLength: number;
  66630. /**
  66631. * Checks if a cullable object (mesh...) is in the camera frustum
  66632. * Unlike isInFrustum this cheks the full bounding box
  66633. * @param frustumPlanes Camera near/planes
  66634. * @returns true if the object is in frustum otherwise false
  66635. */
  66636. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66637. /** @hidden */
  66638. _checkCollision(collider: Collider): boolean;
  66639. /**
  66640. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66641. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66642. * @param point the point to check intersection with
  66643. * @returns if the point intersects
  66644. */
  66645. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66646. /**
  66647. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66648. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66649. * @param boundingInfo the bounding info to check intersection with
  66650. * @param precise if the intersection should be done using OBB
  66651. * @returns if the bounding info intersects
  66652. */
  66653. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66654. }
  66655. }
  66656. declare module BABYLON {
  66657. /**
  66658. * Defines an array and its length.
  66659. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66660. */
  66661. export interface ISmartArrayLike<T> {
  66662. /**
  66663. * The data of the array.
  66664. */
  66665. data: Array<T>;
  66666. /**
  66667. * The active length of the array.
  66668. */
  66669. length: number;
  66670. }
  66671. /**
  66672. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66673. */
  66674. export class SmartArray<T> implements ISmartArrayLike<T> {
  66675. /**
  66676. * The full set of data from the array.
  66677. */
  66678. data: Array<T>;
  66679. /**
  66680. * The active length of the array.
  66681. */
  66682. length: number;
  66683. protected _id: number;
  66684. /**
  66685. * Instantiates a Smart Array.
  66686. * @param capacity defines the default capacity of the array.
  66687. */
  66688. constructor(capacity: number);
  66689. /**
  66690. * Pushes a value at the end of the active data.
  66691. * @param value defines the object to push in the array.
  66692. */
  66693. push(value: T): void;
  66694. /**
  66695. * Iterates over the active data and apply the lambda to them.
  66696. * @param func defines the action to apply on each value.
  66697. */
  66698. forEach(func: (content: T) => void): void;
  66699. /**
  66700. * Sorts the full sets of data.
  66701. * @param compareFn defines the comparison function to apply.
  66702. */
  66703. sort(compareFn: (a: T, b: T) => number): void;
  66704. /**
  66705. * Resets the active data to an empty array.
  66706. */
  66707. reset(): void;
  66708. /**
  66709. * Releases all the data from the array as well as the array.
  66710. */
  66711. dispose(): void;
  66712. /**
  66713. * Concats the active data with a given array.
  66714. * @param array defines the data to concatenate with.
  66715. */
  66716. concat(array: any): void;
  66717. /**
  66718. * Returns the position of a value in the active data.
  66719. * @param value defines the value to find the index for
  66720. * @returns the index if found in the active data otherwise -1
  66721. */
  66722. indexOf(value: T): number;
  66723. /**
  66724. * Returns whether an element is part of the active data.
  66725. * @param value defines the value to look for
  66726. * @returns true if found in the active data otherwise false
  66727. */
  66728. contains(value: T): boolean;
  66729. private static _GlobalId;
  66730. }
  66731. /**
  66732. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66733. * The data in this array can only be present once
  66734. */
  66735. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66736. private _duplicateId;
  66737. /**
  66738. * Pushes a value at the end of the active data.
  66739. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66740. * @param value defines the object to push in the array.
  66741. */
  66742. push(value: T): void;
  66743. /**
  66744. * Pushes a value at the end of the active data.
  66745. * If the data is already present, it won t be added again
  66746. * @param value defines the object to push in the array.
  66747. * @returns true if added false if it was already present
  66748. */
  66749. pushNoDuplicate(value: T): boolean;
  66750. /**
  66751. * Resets the active data to an empty array.
  66752. */
  66753. reset(): void;
  66754. /**
  66755. * Concats the active data with a given array.
  66756. * This ensures no dupplicate will be present in the result.
  66757. * @param array defines the data to concatenate with.
  66758. */
  66759. concatWithNoDuplicate(array: any): void;
  66760. }
  66761. }
  66762. declare module BABYLON {
  66763. /**
  66764. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66765. * separate meshes. This can be use to improve performances.
  66766. * @see http://doc.babylonjs.com/how_to/multi_materials
  66767. */
  66768. export class MultiMaterial extends Material {
  66769. private _subMaterials;
  66770. /**
  66771. * Gets or Sets the list of Materials used within the multi material.
  66772. * They need to be ordered according to the submeshes order in the associated mesh
  66773. */
  66774. subMaterials: Nullable<Material>[];
  66775. /**
  66776. * Function used to align with Node.getChildren()
  66777. * @returns the list of Materials used within the multi material
  66778. */
  66779. getChildren(): Nullable<Material>[];
  66780. /**
  66781. * Instantiates a new Multi Material
  66782. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66783. * separate meshes. This can be use to improve performances.
  66784. * @see http://doc.babylonjs.com/how_to/multi_materials
  66785. * @param name Define the name in the scene
  66786. * @param scene Define the scene the material belongs to
  66787. */
  66788. constructor(name: string, scene: Scene);
  66789. private _hookArray;
  66790. /**
  66791. * Get one of the submaterial by its index in the submaterials array
  66792. * @param index The index to look the sub material at
  66793. * @returns The Material if the index has been defined
  66794. */
  66795. getSubMaterial(index: number): Nullable<Material>;
  66796. /**
  66797. * Get the list of active textures for the whole sub materials list.
  66798. * @returns All the textures that will be used during the rendering
  66799. */
  66800. getActiveTextures(): BaseTexture[];
  66801. /**
  66802. * Gets the current class name of the material e.g. "MultiMaterial"
  66803. * Mainly use in serialization.
  66804. * @returns the class name
  66805. */
  66806. getClassName(): string;
  66807. /**
  66808. * Checks if the material is ready to render the requested sub mesh
  66809. * @param mesh Define the mesh the submesh belongs to
  66810. * @param subMesh Define the sub mesh to look readyness for
  66811. * @param useInstances Define whether or not the material is used with instances
  66812. * @returns true if ready, otherwise false
  66813. */
  66814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66815. /**
  66816. * Clones the current material and its related sub materials
  66817. * @param name Define the name of the newly cloned material
  66818. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66819. * @returns the cloned material
  66820. */
  66821. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66822. /**
  66823. * Serializes the materials into a JSON representation.
  66824. * @returns the JSON representation
  66825. */
  66826. serialize(): any;
  66827. /**
  66828. * Dispose the material and release its associated resources
  66829. * @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)
  66830. * @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)
  66831. * @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)
  66832. */
  66833. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66834. /**
  66835. * Creates a MultiMaterial from parsed MultiMaterial data.
  66836. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66837. * @param scene defines the hosting scene
  66838. * @returns a new MultiMaterial
  66839. */
  66840. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66841. }
  66842. }
  66843. declare module BABYLON {
  66844. /**
  66845. * Class used to represent data loading progression
  66846. */
  66847. export class SceneLoaderFlags {
  66848. private static _ForceFullSceneLoadingForIncremental;
  66849. private static _ShowLoadingScreen;
  66850. private static _CleanBoneMatrixWeights;
  66851. private static _loggingLevel;
  66852. /**
  66853. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66854. */
  66855. static ForceFullSceneLoadingForIncremental: boolean;
  66856. /**
  66857. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66858. */
  66859. static ShowLoadingScreen: boolean;
  66860. /**
  66861. * Defines the current logging level (while loading the scene)
  66862. * @ignorenaming
  66863. */
  66864. static loggingLevel: number;
  66865. /**
  66866. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  66867. */
  66868. static CleanBoneMatrixWeights: boolean;
  66869. }
  66870. }
  66871. declare module BABYLON {
  66872. /**
  66873. * 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.
  66874. * @see https://doc.babylonjs.com/how_to/transformnode
  66875. */
  66876. export class TransformNode extends Node {
  66877. /**
  66878. * Object will not rotate to face the camera
  66879. */
  66880. static BILLBOARDMODE_NONE: number;
  66881. /**
  66882. * Object will rotate to face the camera but only on the x axis
  66883. */
  66884. static BILLBOARDMODE_X: number;
  66885. /**
  66886. * Object will rotate to face the camera but only on the y axis
  66887. */
  66888. static BILLBOARDMODE_Y: number;
  66889. /**
  66890. * Object will rotate to face the camera but only on the z axis
  66891. */
  66892. static BILLBOARDMODE_Z: number;
  66893. /**
  66894. * Object will rotate to face the camera
  66895. */
  66896. static BILLBOARDMODE_ALL: number;
  66897. private _forward;
  66898. private _forwardInverted;
  66899. private _up;
  66900. private _right;
  66901. private _rightInverted;
  66902. private _position;
  66903. private _rotation;
  66904. private _rotationQuaternion;
  66905. protected _scaling: Vector3;
  66906. protected _isDirty: boolean;
  66907. private _transformToBoneReferal;
  66908. private _billboardMode;
  66909. /**
  66910. * Gets or sets the billboard mode. Default is 0.
  66911. *
  66912. * | Value | Type | Description |
  66913. * | --- | --- | --- |
  66914. * | 0 | BILLBOARDMODE_NONE | |
  66915. * | 1 | BILLBOARDMODE_X | |
  66916. * | 2 | BILLBOARDMODE_Y | |
  66917. * | 4 | BILLBOARDMODE_Z | |
  66918. * | 7 | BILLBOARDMODE_ALL | |
  66919. *
  66920. */
  66921. billboardMode: number;
  66922. private _preserveParentRotationForBillboard;
  66923. /**
  66924. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  66925. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  66926. */
  66927. preserveParentRotationForBillboard: boolean;
  66928. /**
  66929. * 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
  66930. */
  66931. scalingDeterminant: number;
  66932. private _infiniteDistance;
  66933. /**
  66934. * Gets or sets the distance of the object to max, often used by skybox
  66935. */
  66936. infiniteDistance: boolean;
  66937. /**
  66938. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  66939. * By default the system will update normals to compensate
  66940. */
  66941. ignoreNonUniformScaling: boolean;
  66942. /**
  66943. * 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
  66944. */
  66945. reIntegrateRotationIntoRotationQuaternion: boolean;
  66946. /** @hidden */
  66947. _poseMatrix: Nullable<Matrix>;
  66948. /** @hidden */
  66949. _localMatrix: Matrix;
  66950. private _usePivotMatrix;
  66951. private _absolutePosition;
  66952. private _pivotMatrix;
  66953. private _pivotMatrixInverse;
  66954. protected _postMultiplyPivotMatrix: boolean;
  66955. protected _isWorldMatrixFrozen: boolean;
  66956. /** @hidden */
  66957. _indexInSceneTransformNodesArray: number;
  66958. /**
  66959. * An event triggered after the world matrix is updated
  66960. */
  66961. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  66962. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  66963. /**
  66964. * Gets a string identifying the name of the class
  66965. * @returns "TransformNode" string
  66966. */
  66967. getClassName(): string;
  66968. /**
  66969. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  66970. */
  66971. position: Vector3;
  66972. /**
  66973. * 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)).
  66974. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  66975. */
  66976. rotation: Vector3;
  66977. /**
  66978. * 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)).
  66979. */
  66980. scaling: Vector3;
  66981. /**
  66982. * 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).
  66983. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  66984. */
  66985. rotationQuaternion: Nullable<Quaternion>;
  66986. /**
  66987. * The forward direction of that transform in world space.
  66988. */
  66989. readonly forward: Vector3;
  66990. /**
  66991. * The up direction of that transform in world space.
  66992. */
  66993. readonly up: Vector3;
  66994. /**
  66995. * The right direction of that transform in world space.
  66996. */
  66997. readonly right: Vector3;
  66998. /**
  66999. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67000. * @param matrix the matrix to copy the pose from
  67001. * @returns this TransformNode.
  67002. */
  67003. updatePoseMatrix(matrix: Matrix): TransformNode;
  67004. /**
  67005. * Returns the mesh Pose matrix.
  67006. * @returns the pose matrix
  67007. */
  67008. getPoseMatrix(): Matrix;
  67009. /** @hidden */
  67010. _isSynchronized(): boolean;
  67011. /** @hidden */
  67012. _initCache(): void;
  67013. /**
  67014. * Flag the transform node as dirty (Forcing it to update everything)
  67015. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67016. * @returns this transform node
  67017. */
  67018. markAsDirty(property: string): TransformNode;
  67019. /**
  67020. * Returns the current mesh absolute position.
  67021. * Returns a Vector3.
  67022. */
  67023. readonly absolutePosition: Vector3;
  67024. /**
  67025. * Sets a new matrix to apply before all other transformation
  67026. * @param matrix defines the transform matrix
  67027. * @returns the current TransformNode
  67028. */
  67029. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67030. /**
  67031. * Sets a new pivot matrix to the current node
  67032. * @param matrix defines the new pivot matrix to use
  67033. * @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
  67034. * @returns the current TransformNode
  67035. */
  67036. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67037. /**
  67038. * Returns the mesh pivot matrix.
  67039. * Default : Identity.
  67040. * @returns the matrix
  67041. */
  67042. getPivotMatrix(): Matrix;
  67043. /**
  67044. * Prevents the World matrix to be computed any longer.
  67045. * @returns the TransformNode.
  67046. */
  67047. freezeWorldMatrix(): TransformNode;
  67048. /**
  67049. * Allows back the World matrix computation.
  67050. * @returns the TransformNode.
  67051. */
  67052. unfreezeWorldMatrix(): this;
  67053. /**
  67054. * True if the World matrix has been frozen.
  67055. */
  67056. readonly isWorldMatrixFrozen: boolean;
  67057. /**
  67058. * Retuns the mesh absolute position in the World.
  67059. * @returns a Vector3.
  67060. */
  67061. getAbsolutePosition(): Vector3;
  67062. /**
  67063. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67064. * @param absolutePosition the absolute position to set
  67065. * @returns the TransformNode.
  67066. */
  67067. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67068. /**
  67069. * Sets the mesh position in its local space.
  67070. * @param vector3 the position to set in localspace
  67071. * @returns the TransformNode.
  67072. */
  67073. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67074. /**
  67075. * Returns the mesh position in the local space from the current World matrix values.
  67076. * @returns a new Vector3.
  67077. */
  67078. getPositionExpressedInLocalSpace(): Vector3;
  67079. /**
  67080. * Translates the mesh along the passed Vector3 in its local space.
  67081. * @param vector3 the distance to translate in localspace
  67082. * @returns the TransformNode.
  67083. */
  67084. locallyTranslate(vector3: Vector3): TransformNode;
  67085. private static _lookAtVectorCache;
  67086. /**
  67087. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67088. * @param targetPoint the position (must be in same space as current mesh) to look at
  67089. * @param yawCor optional yaw (y-axis) correction in radians
  67090. * @param pitchCor optional pitch (x-axis) correction in radians
  67091. * @param rollCor optional roll (z-axis) correction in radians
  67092. * @param space the choosen space of the target
  67093. * @returns the TransformNode.
  67094. */
  67095. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67096. /**
  67097. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67098. * This Vector3 is expressed in the World space.
  67099. * @param localAxis axis to rotate
  67100. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67101. */
  67102. getDirection(localAxis: Vector3): Vector3;
  67103. /**
  67104. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67105. * localAxis is expressed in the mesh local space.
  67106. * result is computed in the Wordl space from the mesh World matrix.
  67107. * @param localAxis axis to rotate
  67108. * @param result the resulting transformnode
  67109. * @returns this TransformNode.
  67110. */
  67111. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67112. /**
  67113. * Sets this transform node rotation to the given local axis.
  67114. * @param localAxis the axis in local space
  67115. * @param yawCor optional yaw (y-axis) correction in radians
  67116. * @param pitchCor optional pitch (x-axis) correction in radians
  67117. * @param rollCor optional roll (z-axis) correction in radians
  67118. * @returns this TransformNode
  67119. */
  67120. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67121. /**
  67122. * Sets a new pivot point to the current node
  67123. * @param point defines the new pivot point to use
  67124. * @param space defines if the point is in world or local space (local by default)
  67125. * @returns the current TransformNode
  67126. */
  67127. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67128. /**
  67129. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67130. * @returns the pivot point
  67131. */
  67132. getPivotPoint(): Vector3;
  67133. /**
  67134. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67135. * @param result the vector3 to store the result
  67136. * @returns this TransformNode.
  67137. */
  67138. getPivotPointToRef(result: Vector3): TransformNode;
  67139. /**
  67140. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67141. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67142. */
  67143. getAbsolutePivotPoint(): Vector3;
  67144. /**
  67145. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67146. * @param result vector3 to store the result
  67147. * @returns this TransformNode.
  67148. */
  67149. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67150. /**
  67151. * Defines the passed node as the parent of the current node.
  67152. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67153. * @see https://doc.babylonjs.com/how_to/parenting
  67154. * @param node the node ot set as the parent
  67155. * @returns this TransformNode.
  67156. */
  67157. setParent(node: Nullable<Node>): TransformNode;
  67158. private _nonUniformScaling;
  67159. /**
  67160. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67161. */
  67162. readonly nonUniformScaling: boolean;
  67163. /** @hidden */
  67164. _updateNonUniformScalingState(value: boolean): boolean;
  67165. /**
  67166. * Attach the current TransformNode to another TransformNode associated with a bone
  67167. * @param bone Bone affecting the TransformNode
  67168. * @param affectedTransformNode TransformNode associated with the bone
  67169. * @returns this object
  67170. */
  67171. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67172. /**
  67173. * Detach the transform node if its associated with a bone
  67174. * @returns this object
  67175. */
  67176. detachFromBone(): TransformNode;
  67177. private static _rotationAxisCache;
  67178. /**
  67179. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67180. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67181. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67182. * The passed axis is also normalized.
  67183. * @param axis the axis to rotate around
  67184. * @param amount the amount to rotate in radians
  67185. * @param space Space to rotate in (Default: local)
  67186. * @returns the TransformNode.
  67187. */
  67188. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67189. /**
  67190. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67191. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67192. * The passed axis is also normalized. .
  67193. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67194. * @param point the point to rotate around
  67195. * @param axis the axis to rotate around
  67196. * @param amount the amount to rotate in radians
  67197. * @returns the TransformNode
  67198. */
  67199. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67200. /**
  67201. * Translates the mesh along the axis vector for the passed distance in the given space.
  67202. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67203. * @param axis the axis to translate in
  67204. * @param distance the distance to translate
  67205. * @param space Space to rotate in (Default: local)
  67206. * @returns the TransformNode.
  67207. */
  67208. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67209. /**
  67210. * Adds a rotation step to the mesh current rotation.
  67211. * x, y, z are Euler angles expressed in radians.
  67212. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67213. * This means this rotation is made in the mesh local space only.
  67214. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67215. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67216. * ```javascript
  67217. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67218. * ```
  67219. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67220. * 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.
  67221. * @param x Rotation to add
  67222. * @param y Rotation to add
  67223. * @param z Rotation to add
  67224. * @returns the TransformNode.
  67225. */
  67226. addRotation(x: number, y: number, z: number): TransformNode;
  67227. /**
  67228. * @hidden
  67229. */
  67230. protected _getEffectiveParent(): Nullable<Node>;
  67231. /**
  67232. * Computes the world matrix of the node
  67233. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67234. * @returns the world matrix
  67235. */
  67236. computeWorldMatrix(force?: boolean): Matrix;
  67237. protected _afterComputeWorldMatrix(): void;
  67238. /**
  67239. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67240. * @param func callback function to add
  67241. *
  67242. * @returns the TransformNode.
  67243. */
  67244. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67245. /**
  67246. * Removes a registered callback function.
  67247. * @param func callback function to remove
  67248. * @returns the TransformNode.
  67249. */
  67250. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67251. /**
  67252. * Gets the position of the current mesh in camera space
  67253. * @param camera defines the camera to use
  67254. * @returns a position
  67255. */
  67256. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67257. /**
  67258. * Returns the distance from the mesh to the active camera
  67259. * @param camera defines the camera to use
  67260. * @returns the distance
  67261. */
  67262. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67263. /**
  67264. * Clone the current transform node
  67265. * @param name Name of the new clone
  67266. * @param newParent New parent for the clone
  67267. * @param doNotCloneChildren Do not clone children hierarchy
  67268. * @returns the new transform node
  67269. */
  67270. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67271. /**
  67272. * Serializes the objects information.
  67273. * @param currentSerializationObject defines the object to serialize in
  67274. * @returns the serialized object
  67275. */
  67276. serialize(currentSerializationObject?: any): any;
  67277. /**
  67278. * Returns a new TransformNode object parsed from the source provided.
  67279. * @param parsedTransformNode is the source.
  67280. * @param scene the scne the object belongs to
  67281. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67282. * @returns a new TransformNode object parsed from the source provided.
  67283. */
  67284. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67285. /**
  67286. * Get all child-transformNodes of this node
  67287. * @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
  67288. * @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
  67289. * @returns an array of TransformNode
  67290. */
  67291. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67292. /**
  67293. * Releases resources associated with this transform node.
  67294. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67295. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67296. */
  67297. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67298. }
  67299. }
  67300. declare module BABYLON {
  67301. /**
  67302. * Class used to override all child animations of a given target
  67303. */
  67304. export class AnimationPropertiesOverride {
  67305. /**
  67306. * Gets or sets a value indicating if animation blending must be used
  67307. */
  67308. enableBlending: boolean;
  67309. /**
  67310. * Gets or sets the blending speed to use when enableBlending is true
  67311. */
  67312. blendingSpeed: number;
  67313. /**
  67314. * Gets or sets the default loop mode to use
  67315. */
  67316. loopMode: number;
  67317. }
  67318. }
  67319. declare module BABYLON {
  67320. /**
  67321. * Class used to store bone information
  67322. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67323. */
  67324. export class Bone extends Node {
  67325. /**
  67326. * defines the bone name
  67327. */
  67328. name: string;
  67329. private static _tmpVecs;
  67330. private static _tmpQuat;
  67331. private static _tmpMats;
  67332. /**
  67333. * Gets the list of child bones
  67334. */
  67335. children: Bone[];
  67336. /** Gets the animations associated with this bone */
  67337. animations: Animation[];
  67338. /**
  67339. * Gets or sets bone length
  67340. */
  67341. length: number;
  67342. /**
  67343. * @hidden Internal only
  67344. * Set this value to map this bone to a different index in the transform matrices
  67345. * Set this value to -1 to exclude the bone from the transform matrices
  67346. */
  67347. _index: Nullable<number>;
  67348. private _skeleton;
  67349. private _localMatrix;
  67350. private _restPose;
  67351. private _baseMatrix;
  67352. private _absoluteTransform;
  67353. private _invertedAbsoluteTransform;
  67354. private _parent;
  67355. private _scalingDeterminant;
  67356. private _worldTransform;
  67357. private _localScaling;
  67358. private _localRotation;
  67359. private _localPosition;
  67360. private _needToDecompose;
  67361. private _needToCompose;
  67362. /** @hidden */
  67363. _linkedTransformNode: Nullable<TransformNode>;
  67364. /** @hidden */
  67365. /** @hidden */
  67366. _matrix: Matrix;
  67367. /**
  67368. * Create a new bone
  67369. * @param name defines the bone name
  67370. * @param skeleton defines the parent skeleton
  67371. * @param parentBone defines the parent (can be null if the bone is the root)
  67372. * @param localMatrix defines the local matrix
  67373. * @param restPose defines the rest pose matrix
  67374. * @param baseMatrix defines the base matrix
  67375. * @param index defines index of the bone in the hiearchy
  67376. */
  67377. constructor(
  67378. /**
  67379. * defines the bone name
  67380. */
  67381. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67382. /**
  67383. * Gets the current object class name.
  67384. * @return the class name
  67385. */
  67386. getClassName(): string;
  67387. /**
  67388. * Gets the parent skeleton
  67389. * @returns a skeleton
  67390. */
  67391. getSkeleton(): Skeleton;
  67392. /**
  67393. * Gets parent bone
  67394. * @returns a bone or null if the bone is the root of the bone hierarchy
  67395. */
  67396. getParent(): Nullable<Bone>;
  67397. /**
  67398. * Returns an array containing the root bones
  67399. * @returns an array containing the root bones
  67400. */
  67401. getChildren(): Array<Bone>;
  67402. /**
  67403. * Sets the parent bone
  67404. * @param parent defines the parent (can be null if the bone is the root)
  67405. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67406. */
  67407. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67408. /**
  67409. * Gets the local matrix
  67410. * @returns a matrix
  67411. */
  67412. getLocalMatrix(): Matrix;
  67413. /**
  67414. * Gets the base matrix (initial matrix which remains unchanged)
  67415. * @returns a matrix
  67416. */
  67417. getBaseMatrix(): Matrix;
  67418. /**
  67419. * Gets the rest pose matrix
  67420. * @returns a matrix
  67421. */
  67422. getRestPose(): Matrix;
  67423. /**
  67424. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67425. */
  67426. getWorldMatrix(): Matrix;
  67427. /**
  67428. * Sets the local matrix to rest pose matrix
  67429. */
  67430. returnToRest(): void;
  67431. /**
  67432. * Gets the inverse of the absolute transform matrix.
  67433. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67434. * @returns a matrix
  67435. */
  67436. getInvertedAbsoluteTransform(): Matrix;
  67437. /**
  67438. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67439. * @returns a matrix
  67440. */
  67441. getAbsoluteTransform(): Matrix;
  67442. /**
  67443. * Links with the given transform node.
  67444. * The local matrix of this bone is copied from the transform node every frame.
  67445. * @param transformNode defines the transform node to link to
  67446. */
  67447. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67448. /** Gets or sets current position (in local space) */
  67449. position: Vector3;
  67450. /** Gets or sets current rotation (in local space) */
  67451. rotation: Vector3;
  67452. /** Gets or sets current rotation quaternion (in local space) */
  67453. rotationQuaternion: Quaternion;
  67454. /** Gets or sets current scaling (in local space) */
  67455. scaling: Vector3;
  67456. /**
  67457. * Gets the animation properties override
  67458. */
  67459. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67460. private _decompose;
  67461. private _compose;
  67462. /**
  67463. * Update the base and local matrices
  67464. * @param matrix defines the new base or local matrix
  67465. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67466. * @param updateLocalMatrix defines if the local matrix should be updated
  67467. */
  67468. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67469. /** @hidden */
  67470. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67471. /**
  67472. * Flag the bone as dirty (Forcing it to update everything)
  67473. */
  67474. markAsDirty(): void;
  67475. private _markAsDirtyAndCompose;
  67476. private _markAsDirtyAndDecompose;
  67477. /**
  67478. * Translate the bone in local or world space
  67479. * @param vec The amount to translate the bone
  67480. * @param space The space that the translation is in
  67481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67482. */
  67483. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67484. /**
  67485. * Set the postion of the bone in local or world space
  67486. * @param position The position to set the bone
  67487. * @param space The space that the position is in
  67488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67489. */
  67490. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67491. /**
  67492. * Set the absolute position of the bone (world space)
  67493. * @param position The position to set the bone
  67494. * @param mesh The mesh that this bone is attached to
  67495. */
  67496. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67497. /**
  67498. * Scale the bone on the x, y and z axes (in local space)
  67499. * @param x The amount to scale the bone on the x axis
  67500. * @param y The amount to scale the bone on the y axis
  67501. * @param z The amount to scale the bone on the z axis
  67502. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67503. */
  67504. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67505. /**
  67506. * Set the bone scaling in local space
  67507. * @param scale defines the scaling vector
  67508. */
  67509. setScale(scale: Vector3): void;
  67510. /**
  67511. * Gets the current scaling in local space
  67512. * @returns the current scaling vector
  67513. */
  67514. getScale(): Vector3;
  67515. /**
  67516. * Gets the current scaling in local space and stores it in a target vector
  67517. * @param result defines the target vector
  67518. */
  67519. getScaleToRef(result: Vector3): void;
  67520. /**
  67521. * Set the yaw, pitch, and roll of the bone in local or world space
  67522. * @param yaw The rotation of the bone on the y axis
  67523. * @param pitch The rotation of the bone on the x axis
  67524. * @param roll The rotation of the bone on the z axis
  67525. * @param space The space that the axes of rotation are in
  67526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67527. */
  67528. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67529. /**
  67530. * Add a rotation to the bone on an axis in local or world space
  67531. * @param axis The axis to rotate the bone on
  67532. * @param amount The amount to rotate the bone
  67533. * @param space The space that the axis is in
  67534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67535. */
  67536. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67537. /**
  67538. * Set the rotation of the bone to a particular axis angle in local or world space
  67539. * @param axis The axis to rotate the bone on
  67540. * @param angle The angle that the bone should be rotated to
  67541. * @param space The space that the axis is in
  67542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67543. */
  67544. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67545. /**
  67546. * Set the euler rotation of the bone in local of world space
  67547. * @param rotation The euler rotation that the bone should be set to
  67548. * @param space The space that the rotation is in
  67549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67550. */
  67551. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67552. /**
  67553. * Set the quaternion rotation of the bone in local of world space
  67554. * @param quat The quaternion rotation that the bone should be set to
  67555. * @param space The space that the rotation is in
  67556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67557. */
  67558. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67559. /**
  67560. * Set the rotation matrix of the bone in local of world space
  67561. * @param rotMat The rotation matrix that the bone should be set to
  67562. * @param space The space that the rotation is in
  67563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67564. */
  67565. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67566. private _rotateWithMatrix;
  67567. private _getNegativeRotationToRef;
  67568. /**
  67569. * Get the position of the bone in local or world space
  67570. * @param space The space that the returned position is in
  67571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67572. * @returns The position of the bone
  67573. */
  67574. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67575. /**
  67576. * Copy the position of the bone to a vector3 in local or world space
  67577. * @param space The space that the returned position is in
  67578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67579. * @param result The vector3 to copy the position to
  67580. */
  67581. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67582. /**
  67583. * Get the absolute position of the bone (world space)
  67584. * @param mesh The mesh that this bone is attached to
  67585. * @returns The absolute position of the bone
  67586. */
  67587. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67588. /**
  67589. * Copy the absolute position of the bone (world space) to the result param
  67590. * @param mesh The mesh that this bone is attached to
  67591. * @param result The vector3 to copy the absolute position to
  67592. */
  67593. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67594. /**
  67595. * Compute the absolute transforms of this bone and its children
  67596. */
  67597. computeAbsoluteTransforms(): void;
  67598. /**
  67599. * Get the world direction from an axis that is in the local space of the bone
  67600. * @param localAxis The local direction that is used to compute the world direction
  67601. * @param mesh The mesh that this bone is attached to
  67602. * @returns The world direction
  67603. */
  67604. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67605. /**
  67606. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67607. * @param localAxis The local direction that is used to compute the world direction
  67608. * @param mesh The mesh that this bone is attached to
  67609. * @param result The vector3 that the world direction will be copied to
  67610. */
  67611. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67612. /**
  67613. * Get the euler rotation of the bone in local or world space
  67614. * @param space The space that the rotation should be in
  67615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67616. * @returns The euler rotation
  67617. */
  67618. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67619. /**
  67620. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67621. * @param space The space that the rotation should be in
  67622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67623. * @param result The vector3 that the rotation should be copied to
  67624. */
  67625. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67626. /**
  67627. * Get the quaternion rotation of the bone in either local or world space
  67628. * @param space The space that the rotation should be in
  67629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67630. * @returns The quaternion rotation
  67631. */
  67632. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67633. /**
  67634. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67635. * @param space The space that the rotation should be in
  67636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67637. * @param result The quaternion that the rotation should be copied to
  67638. */
  67639. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67640. /**
  67641. * Get the rotation matrix of the bone in local or world space
  67642. * @param space The space that the rotation should be in
  67643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67644. * @returns The rotation matrix
  67645. */
  67646. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67647. /**
  67648. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67649. * @param space The space that the rotation should be in
  67650. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67651. * @param result The quaternion that the rotation should be copied to
  67652. */
  67653. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67654. /**
  67655. * Get the world position of a point that is in the local space of the bone
  67656. * @param position The local position
  67657. * @param mesh The mesh that this bone is attached to
  67658. * @returns The world position
  67659. */
  67660. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67661. /**
  67662. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67663. * @param position The local position
  67664. * @param mesh The mesh that this bone is attached to
  67665. * @param result The vector3 that the world position should be copied to
  67666. */
  67667. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67668. /**
  67669. * Get the local position of a point that is in world space
  67670. * @param position The world position
  67671. * @param mesh The mesh that this bone is attached to
  67672. * @returns The local position
  67673. */
  67674. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67675. /**
  67676. * Get the local position of a point that is in world space and copy it to the result param
  67677. * @param position The world position
  67678. * @param mesh The mesh that this bone is attached to
  67679. * @param result The vector3 that the local position should be copied to
  67680. */
  67681. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67682. }
  67683. }
  67684. declare module BABYLON {
  67685. /**
  67686. * Enum that determines the text-wrapping mode to use.
  67687. */
  67688. export enum InspectableType {
  67689. /**
  67690. * Checkbox for booleans
  67691. */
  67692. Checkbox = 0,
  67693. /**
  67694. * Sliders for numbers
  67695. */
  67696. Slider = 1,
  67697. /**
  67698. * Vector3
  67699. */
  67700. Vector3 = 2,
  67701. /**
  67702. * Quaternions
  67703. */
  67704. Quaternion = 3,
  67705. /**
  67706. * Color3
  67707. */
  67708. Color3 = 4
  67709. }
  67710. /**
  67711. * Interface used to define custom inspectable properties.
  67712. * This interface is used by the inspector to display custom property grids
  67713. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67714. */
  67715. export interface IInspectable {
  67716. /**
  67717. * Gets the label to display
  67718. */
  67719. label: string;
  67720. /**
  67721. * Gets the name of the property to edit
  67722. */
  67723. propertyName: string;
  67724. /**
  67725. * Gets the type of the editor to use
  67726. */
  67727. type: InspectableType;
  67728. /**
  67729. * Gets the minimum value of the property when using in "slider" mode
  67730. */
  67731. min?: number;
  67732. /**
  67733. * Gets the maximum value of the property when using in "slider" mode
  67734. */
  67735. max?: number;
  67736. /**
  67737. * Gets the setp to use when using in "slider" mode
  67738. */
  67739. step?: number;
  67740. }
  67741. }
  67742. declare module BABYLON {
  67743. /**
  67744. * Class for creating a cube texture
  67745. */
  67746. export class CubeTexture extends BaseTexture {
  67747. private _delayedOnLoad;
  67748. /**
  67749. * The url of the texture
  67750. */
  67751. url: string;
  67752. /**
  67753. * Gets or sets the center of the bounding box associated with the cube texture.
  67754. * It must define where the camera used to render the texture was set
  67755. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67756. */
  67757. boundingBoxPosition: Vector3;
  67758. private _boundingBoxSize;
  67759. /**
  67760. * Gets or sets the size of the bounding box associated with the cube texture
  67761. * When defined, the cubemap will switch to local mode
  67762. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67763. * @example https://www.babylonjs-playground.com/#RNASML
  67764. */
  67765. /**
  67766. * Returns the bounding box size
  67767. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67768. */
  67769. boundingBoxSize: Vector3;
  67770. protected _rotationY: number;
  67771. /**
  67772. * Sets texture matrix rotation angle around Y axis in radians.
  67773. */
  67774. /**
  67775. * Gets texture matrix rotation angle around Y axis radians.
  67776. */
  67777. rotationY: number;
  67778. /**
  67779. * Are mip maps generated for this texture or not.
  67780. */
  67781. readonly noMipmap: boolean;
  67782. private _noMipmap;
  67783. private _files;
  67784. private _extensions;
  67785. private _textureMatrix;
  67786. private _format;
  67787. private _createPolynomials;
  67788. /** @hidden */
  67789. _prefiltered: boolean;
  67790. /**
  67791. * Creates a cube texture from an array of image urls
  67792. * @param files defines an array of image urls
  67793. * @param scene defines the hosting scene
  67794. * @param noMipmap specifies if mip maps are not used
  67795. * @returns a cube texture
  67796. */
  67797. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67798. /**
  67799. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67800. * @param url defines the url of the prefiltered texture
  67801. * @param scene defines the scene the texture is attached to
  67802. * @param forcedExtension defines the extension of the file if different from the url
  67803. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67804. * @return the prefiltered texture
  67805. */
  67806. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67807. /**
  67808. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67809. * as prefiltered data.
  67810. * @param rootUrl defines the url of the texture or the root name of the six images
  67811. * @param scene defines the scene the texture is attached to
  67812. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67813. * @param noMipmap defines if mipmaps should be created or not
  67814. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67815. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67816. * @param onError defines a callback triggered in case of error during load
  67817. * @param format defines the internal format to use for the texture once loaded
  67818. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67819. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67820. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67821. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67822. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67823. * @return the cube texture
  67824. */
  67825. 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);
  67826. /**
  67827. * Get the current class name of the texture useful for serialization or dynamic coding.
  67828. * @returns "CubeTexture"
  67829. */
  67830. getClassName(): string;
  67831. /**
  67832. * Update the url (and optional buffer) of this texture if url was null during construction.
  67833. * @param url the url of the texture
  67834. * @param forcedExtension defines the extension to use
  67835. * @param onLoad callback called when the texture is loaded (defaults to null)
  67836. */
  67837. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67838. /**
  67839. * Delays loading of the cube texture
  67840. * @param forcedExtension defines the extension to use
  67841. */
  67842. delayLoad(forcedExtension?: string): void;
  67843. /**
  67844. * Returns the reflection texture matrix
  67845. * @returns the reflection texture matrix
  67846. */
  67847. getReflectionTextureMatrix(): Matrix;
  67848. /**
  67849. * Sets the reflection texture matrix
  67850. * @param value Reflection texture matrix
  67851. */
  67852. setReflectionTextureMatrix(value: Matrix): void;
  67853. /**
  67854. * Parses text to create a cube texture
  67855. * @param parsedTexture define the serialized text to read from
  67856. * @param scene defines the hosting scene
  67857. * @param rootUrl defines the root url of the cube texture
  67858. * @returns a cube texture
  67859. */
  67860. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  67861. /**
  67862. * Makes a clone, or deep copy, of the cube texture
  67863. * @returns a new cube texture
  67864. */
  67865. clone(): CubeTexture;
  67866. }
  67867. }
  67868. declare module BABYLON {
  67869. /** @hidden */
  67870. export var postprocessVertexShader: {
  67871. name: string;
  67872. shader: string;
  67873. };
  67874. }
  67875. declare module BABYLON {
  67876. /**
  67877. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  67878. * This is the base of the follow, arc rotate cameras and Free camera
  67879. * @see http://doc.babylonjs.com/features/cameras
  67880. */
  67881. export class TargetCamera extends Camera {
  67882. private static _RigCamTransformMatrix;
  67883. private static _TargetTransformMatrix;
  67884. private static _TargetFocalPoint;
  67885. /**
  67886. * Define the current direction the camera is moving to
  67887. */
  67888. cameraDirection: Vector3;
  67889. /**
  67890. * Define the current rotation the camera is rotating to
  67891. */
  67892. cameraRotation: Vector2;
  67893. /**
  67894. * When set, the up vector of the camera will be updated by the rotation of the camera
  67895. */
  67896. updateUpVectorFromRotation: boolean;
  67897. private _tmpQuaternion;
  67898. /**
  67899. * Define the current rotation of the camera
  67900. */
  67901. rotation: Vector3;
  67902. /**
  67903. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  67904. */
  67905. rotationQuaternion: Quaternion;
  67906. /**
  67907. * Define the current speed of the camera
  67908. */
  67909. speed: number;
  67910. /**
  67911. * Add cconstraint to the camera to prevent it to move freely in all directions and
  67912. * around all axis.
  67913. */
  67914. noRotationConstraint: boolean;
  67915. /**
  67916. * Define the current target of the camera as an object or a position.
  67917. */
  67918. lockedTarget: any;
  67919. /** @hidden */
  67920. _currentTarget: Vector3;
  67921. /** @hidden */
  67922. _initialFocalDistance: number;
  67923. /** @hidden */
  67924. _viewMatrix: Matrix;
  67925. /** @hidden */
  67926. _camMatrix: Matrix;
  67927. /** @hidden */
  67928. _cameraTransformMatrix: Matrix;
  67929. /** @hidden */
  67930. _cameraRotationMatrix: Matrix;
  67931. /** @hidden */
  67932. _referencePoint: Vector3;
  67933. /** @hidden */
  67934. _transformedReferencePoint: Vector3;
  67935. protected _globalCurrentTarget: Vector3;
  67936. protected _globalCurrentUpVector: Vector3;
  67937. /** @hidden */
  67938. _reset: () => void;
  67939. private _defaultUp;
  67940. /**
  67941. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  67942. * This is the base of the follow, arc rotate cameras and Free camera
  67943. * @see http://doc.babylonjs.com/features/cameras
  67944. * @param name Defines the name of the camera in the scene
  67945. * @param position Defines the start position of the camera in the scene
  67946. * @param scene Defines the scene the camera belongs to
  67947. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  67948. */
  67949. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  67950. /**
  67951. * Gets the position in front of the camera at a given distance.
  67952. * @param distance The distance from the camera we want the position to be
  67953. * @returns the position
  67954. */
  67955. getFrontPosition(distance: number): Vector3;
  67956. /** @hidden */
  67957. _getLockedTargetPosition(): Nullable<Vector3>;
  67958. private _storedPosition;
  67959. private _storedRotation;
  67960. private _storedRotationQuaternion;
  67961. /**
  67962. * Store current camera state of the camera (fov, position, rotation, etc..)
  67963. * @returns the camera
  67964. */
  67965. storeState(): Camera;
  67966. /**
  67967. * Restored camera state. You must call storeState() first
  67968. * @returns whether it was successful or not
  67969. * @hidden
  67970. */
  67971. _restoreStateValues(): boolean;
  67972. /** @hidden */
  67973. _initCache(): void;
  67974. /** @hidden */
  67975. _updateCache(ignoreParentClass?: boolean): void;
  67976. /** @hidden */
  67977. _isSynchronizedViewMatrix(): boolean;
  67978. /** @hidden */
  67979. _computeLocalCameraSpeed(): number;
  67980. /**
  67981. * Defines the target the camera should look at.
  67982. * This will automatically adapt alpha beta and radius to fit within the new target.
  67983. * @param target Defines the new target as a Vector or a mesh
  67984. */
  67985. setTarget(target: Vector3): void;
  67986. /**
  67987. * Return the current target position of the camera. This value is expressed in local space.
  67988. * @returns the target position
  67989. */
  67990. getTarget(): Vector3;
  67991. /** @hidden */
  67992. _decideIfNeedsToMove(): boolean;
  67993. /** @hidden */
  67994. _updatePosition(): void;
  67995. /** @hidden */
  67996. _checkInputs(): void;
  67997. protected _updateCameraRotationMatrix(): void;
  67998. /**
  67999. * 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)
  68000. * @returns the current camera
  68001. */
  68002. private _rotateUpVectorWithCameraRotationMatrix;
  68003. private _cachedRotationZ;
  68004. private _cachedQuaternionRotationZ;
  68005. /** @hidden */
  68006. _getViewMatrix(): Matrix;
  68007. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68008. /**
  68009. * @hidden
  68010. */
  68011. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68012. /**
  68013. * @hidden
  68014. */
  68015. _updateRigCameras(): void;
  68016. private _getRigCamPositionAndTarget;
  68017. /**
  68018. * Gets the current object class name.
  68019. * @return the class name
  68020. */
  68021. getClassName(): string;
  68022. }
  68023. }
  68024. declare module BABYLON {
  68025. /**
  68026. * @ignore
  68027. * This is a list of all the different input types that are available in the application.
  68028. * Fo instance: ArcRotateCameraGamepadInput...
  68029. */
  68030. export var CameraInputTypes: {};
  68031. /**
  68032. * This is the contract to implement in order to create a new input class.
  68033. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68034. */
  68035. export interface ICameraInput<TCamera extends Camera> {
  68036. /**
  68037. * Defines the camera the input is attached to.
  68038. */
  68039. camera: Nullable<TCamera>;
  68040. /**
  68041. * Gets the class name of the current intput.
  68042. * @returns the class name
  68043. */
  68044. getClassName(): string;
  68045. /**
  68046. * Get the friendly name associated with the input class.
  68047. * @returns the input friendly name
  68048. */
  68049. getSimpleName(): string;
  68050. /**
  68051. * Attach the input controls to a specific dom element to get the input from.
  68052. * @param element Defines the element the controls should be listened from
  68053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68054. */
  68055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68056. /**
  68057. * Detach the current controls from the specified dom element.
  68058. * @param element Defines the element to stop listening the inputs from
  68059. */
  68060. detachControl(element: Nullable<HTMLElement>): void;
  68061. /**
  68062. * Update the current camera state depending on the inputs that have been used this frame.
  68063. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68064. */
  68065. checkInputs?: () => void;
  68066. }
  68067. /**
  68068. * Represents a map of input types to input instance or input index to input instance.
  68069. */
  68070. export interface CameraInputsMap<TCamera extends Camera> {
  68071. /**
  68072. * Accessor to the input by input type.
  68073. */
  68074. [name: string]: ICameraInput<TCamera>;
  68075. /**
  68076. * Accessor to the input by input index.
  68077. */
  68078. [idx: number]: ICameraInput<TCamera>;
  68079. }
  68080. /**
  68081. * This represents the input manager used within a camera.
  68082. * It helps dealing with all the different kind of input attached to a camera.
  68083. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68084. */
  68085. export class CameraInputsManager<TCamera extends Camera> {
  68086. /**
  68087. * Defines the list of inputs attahed to the camera.
  68088. */
  68089. attached: CameraInputsMap<TCamera>;
  68090. /**
  68091. * Defines the dom element the camera is collecting inputs from.
  68092. * This is null if the controls have not been attached.
  68093. */
  68094. attachedElement: Nullable<HTMLElement>;
  68095. /**
  68096. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68097. */
  68098. noPreventDefault: boolean;
  68099. /**
  68100. * Defined the camera the input manager belongs to.
  68101. */
  68102. camera: TCamera;
  68103. /**
  68104. * Update the current camera state depending on the inputs that have been used this frame.
  68105. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68106. */
  68107. checkInputs: () => void;
  68108. /**
  68109. * Instantiate a new Camera Input Manager.
  68110. * @param camera Defines the camera the input manager blongs to
  68111. */
  68112. constructor(camera: TCamera);
  68113. /**
  68114. * Add an input method to a camera
  68115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68116. * @param input camera input method
  68117. */
  68118. add(input: ICameraInput<TCamera>): void;
  68119. /**
  68120. * Remove a specific input method from a camera
  68121. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68122. * @param inputToRemove camera input method
  68123. */
  68124. remove(inputToRemove: ICameraInput<TCamera>): void;
  68125. /**
  68126. * Remove a specific input type from a camera
  68127. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68128. * @param inputType the type of the input to remove
  68129. */
  68130. removeByType(inputType: string): void;
  68131. private _addCheckInputs;
  68132. /**
  68133. * Attach the input controls to the currently attached dom element to listen the events from.
  68134. * @param input Defines the input to attach
  68135. */
  68136. attachInput(input: ICameraInput<TCamera>): void;
  68137. /**
  68138. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68139. * @param element Defines the dom element to collect the events from
  68140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68141. */
  68142. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68143. /**
  68144. * Detach the current manager inputs controls from a specific dom element.
  68145. * @param element Defines the dom element to collect the events from
  68146. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68147. */
  68148. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68149. /**
  68150. * Rebuild the dynamic inputCheck function from the current list of
  68151. * defined inputs in the manager.
  68152. */
  68153. rebuildInputCheck(): void;
  68154. /**
  68155. * Remove all attached input methods from a camera
  68156. */
  68157. clear(): void;
  68158. /**
  68159. * Serialize the current input manager attached to a camera.
  68160. * This ensures than once parsed,
  68161. * the input associated to the camera will be identical to the current ones
  68162. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68163. */
  68164. serialize(serializedCamera: any): void;
  68165. /**
  68166. * Parses an input manager serialized JSON to restore the previous list of inputs
  68167. * and states associated to a camera.
  68168. * @param parsedCamera Defines the JSON to parse
  68169. */
  68170. parse(parsedCamera: any): void;
  68171. }
  68172. }
  68173. declare module BABYLON {
  68174. /**
  68175. * Gather the list of keyboard event types as constants.
  68176. */
  68177. export class KeyboardEventTypes {
  68178. /**
  68179. * The keydown event is fired when a key becomes active (pressed).
  68180. */
  68181. static readonly KEYDOWN: number;
  68182. /**
  68183. * The keyup event is fired when a key has been released.
  68184. */
  68185. static readonly KEYUP: number;
  68186. }
  68187. /**
  68188. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68189. */
  68190. export class KeyboardInfo {
  68191. /**
  68192. * Defines the type of event (KeyboardEventTypes)
  68193. */
  68194. type: number;
  68195. /**
  68196. * Defines the related dom event
  68197. */
  68198. event: KeyboardEvent;
  68199. /**
  68200. * Instantiates a new keyboard info.
  68201. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68202. * @param type Defines the type of event (KeyboardEventTypes)
  68203. * @param event Defines the related dom event
  68204. */
  68205. constructor(
  68206. /**
  68207. * Defines the type of event (KeyboardEventTypes)
  68208. */
  68209. type: number,
  68210. /**
  68211. * Defines the related dom event
  68212. */
  68213. event: KeyboardEvent);
  68214. }
  68215. /**
  68216. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68217. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68218. */
  68219. export class KeyboardInfoPre extends KeyboardInfo {
  68220. /**
  68221. * Defines the type of event (KeyboardEventTypes)
  68222. */
  68223. type: number;
  68224. /**
  68225. * Defines the related dom event
  68226. */
  68227. event: KeyboardEvent;
  68228. /**
  68229. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68230. */
  68231. skipOnPointerObservable: boolean;
  68232. /**
  68233. * Instantiates a new keyboard pre info.
  68234. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68235. * @param type Defines the type of event (KeyboardEventTypes)
  68236. * @param event Defines the related dom event
  68237. */
  68238. constructor(
  68239. /**
  68240. * Defines the type of event (KeyboardEventTypes)
  68241. */
  68242. type: number,
  68243. /**
  68244. * Defines the related dom event
  68245. */
  68246. event: KeyboardEvent);
  68247. }
  68248. }
  68249. declare module BABYLON {
  68250. /**
  68251. * Manage the keyboard inputs to control the movement of a free camera.
  68252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68253. */
  68254. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68255. /**
  68256. * Defines the camera the input is attached to.
  68257. */
  68258. camera: FreeCamera;
  68259. /**
  68260. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68261. */
  68262. keysUp: number[];
  68263. /**
  68264. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68265. */
  68266. keysDown: number[];
  68267. /**
  68268. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68269. */
  68270. keysLeft: number[];
  68271. /**
  68272. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68273. */
  68274. keysRight: number[];
  68275. private _keys;
  68276. private _onCanvasBlurObserver;
  68277. private _onKeyboardObserver;
  68278. private _engine;
  68279. private _scene;
  68280. /**
  68281. * Attach the input controls to a specific dom element to get the input from.
  68282. * @param element Defines the element the controls should be listened from
  68283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68284. */
  68285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68286. /**
  68287. * Detach the current controls from the specified dom element.
  68288. * @param element Defines the element to stop listening the inputs from
  68289. */
  68290. detachControl(element: Nullable<HTMLElement>): void;
  68291. /**
  68292. * Update the current camera state depending on the inputs that have been used this frame.
  68293. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68294. */
  68295. checkInputs(): void;
  68296. /**
  68297. * Gets the class name of the current intput.
  68298. * @returns the class name
  68299. */
  68300. getClassName(): string;
  68301. /** @hidden */
  68302. _onLostFocus(): void;
  68303. /**
  68304. * Get the friendly name associated with the input class.
  68305. * @returns the input friendly name
  68306. */
  68307. getSimpleName(): string;
  68308. }
  68309. }
  68310. declare module BABYLON {
  68311. /**
  68312. * Interface describing all the common properties and methods a shadow light needs to implement.
  68313. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68314. * as well as binding the different shadow properties to the effects.
  68315. */
  68316. export interface IShadowLight extends Light {
  68317. /**
  68318. * The light id in the scene (used in scene.findLighById for instance)
  68319. */
  68320. id: string;
  68321. /**
  68322. * The position the shdow will be casted from.
  68323. */
  68324. position: Vector3;
  68325. /**
  68326. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68327. */
  68328. direction: Vector3;
  68329. /**
  68330. * The transformed position. Position of the light in world space taking parenting in account.
  68331. */
  68332. transformedPosition: Vector3;
  68333. /**
  68334. * The transformed direction. Direction of the light in world space taking parenting in account.
  68335. */
  68336. transformedDirection: Vector3;
  68337. /**
  68338. * The friendly name of the light in the scene.
  68339. */
  68340. name: string;
  68341. /**
  68342. * Defines the shadow projection clipping minimum z value.
  68343. */
  68344. shadowMinZ: number;
  68345. /**
  68346. * Defines the shadow projection clipping maximum z value.
  68347. */
  68348. shadowMaxZ: number;
  68349. /**
  68350. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68351. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68352. */
  68353. computeTransformedInformation(): boolean;
  68354. /**
  68355. * Gets the scene the light belongs to.
  68356. * @returns The scene
  68357. */
  68358. getScene(): Scene;
  68359. /**
  68360. * Callback defining a custom Projection Matrix Builder.
  68361. * This can be used to override the default projection matrix computation.
  68362. */
  68363. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68364. /**
  68365. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68366. * @param matrix The materix to updated with the projection information
  68367. * @param viewMatrix The transform matrix of the light
  68368. * @param renderList The list of mesh to render in the map
  68369. * @returns The current light
  68370. */
  68371. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68372. /**
  68373. * Gets the current depth scale used in ESM.
  68374. * @returns The scale
  68375. */
  68376. getDepthScale(): number;
  68377. /**
  68378. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68379. * @returns true if a cube texture needs to be use
  68380. */
  68381. needCube(): boolean;
  68382. /**
  68383. * Detects if the projection matrix requires to be recomputed this frame.
  68384. * @returns true if it requires to be recomputed otherwise, false.
  68385. */
  68386. needProjectionMatrixCompute(): boolean;
  68387. /**
  68388. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68389. */
  68390. forceProjectionMatrixCompute(): void;
  68391. /**
  68392. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68393. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68394. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68395. */
  68396. getShadowDirection(faceIndex?: number): Vector3;
  68397. /**
  68398. * Gets the minZ used for shadow according to both the scene and the light.
  68399. * @param activeCamera The camera we are returning the min for
  68400. * @returns the depth min z
  68401. */
  68402. getDepthMinZ(activeCamera: Camera): number;
  68403. /**
  68404. * Gets the maxZ used for shadow according to both the scene and the light.
  68405. * @param activeCamera The camera we are returning the max for
  68406. * @returns the depth max z
  68407. */
  68408. getDepthMaxZ(activeCamera: Camera): number;
  68409. }
  68410. /**
  68411. * Base implementation IShadowLight
  68412. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68413. */
  68414. export abstract class ShadowLight extends Light implements IShadowLight {
  68415. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68416. protected _position: Vector3;
  68417. protected _setPosition(value: Vector3): void;
  68418. /**
  68419. * Sets the position the shadow will be casted from. Also use as the light position for both
  68420. * point and spot lights.
  68421. */
  68422. /**
  68423. * Sets the position the shadow will be casted from. Also use as the light position for both
  68424. * point and spot lights.
  68425. */
  68426. position: Vector3;
  68427. protected _direction: Vector3;
  68428. protected _setDirection(value: Vector3): void;
  68429. /**
  68430. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68431. * Also use as the light direction on spot and directional lights.
  68432. */
  68433. /**
  68434. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68435. * Also use as the light direction on spot and directional lights.
  68436. */
  68437. direction: Vector3;
  68438. private _shadowMinZ;
  68439. /**
  68440. * Gets the shadow projection clipping minimum z value.
  68441. */
  68442. /**
  68443. * Sets the shadow projection clipping minimum z value.
  68444. */
  68445. shadowMinZ: number;
  68446. private _shadowMaxZ;
  68447. /**
  68448. * Sets the shadow projection clipping maximum z value.
  68449. */
  68450. /**
  68451. * Gets the shadow projection clipping maximum z value.
  68452. */
  68453. shadowMaxZ: number;
  68454. /**
  68455. * Callback defining a custom Projection Matrix Builder.
  68456. * This can be used to override the default projection matrix computation.
  68457. */
  68458. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68459. /**
  68460. * The transformed position. Position of the light in world space taking parenting in account.
  68461. */
  68462. transformedPosition: Vector3;
  68463. /**
  68464. * The transformed direction. Direction of the light in world space taking parenting in account.
  68465. */
  68466. transformedDirection: Vector3;
  68467. private _needProjectionMatrixCompute;
  68468. /**
  68469. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68470. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68471. */
  68472. computeTransformedInformation(): boolean;
  68473. /**
  68474. * Return the depth scale used for the shadow map.
  68475. * @returns the depth scale.
  68476. */
  68477. getDepthScale(): number;
  68478. /**
  68479. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68480. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68481. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68482. */
  68483. getShadowDirection(faceIndex?: number): Vector3;
  68484. /**
  68485. * Returns the ShadowLight absolute position in the World.
  68486. * @returns the position vector in world space
  68487. */
  68488. getAbsolutePosition(): Vector3;
  68489. /**
  68490. * Sets the ShadowLight direction toward the passed target.
  68491. * @param target The point to target in local space
  68492. * @returns the updated ShadowLight direction
  68493. */
  68494. setDirectionToTarget(target: Vector3): Vector3;
  68495. /**
  68496. * Returns the light rotation in euler definition.
  68497. * @returns the x y z rotation in local space.
  68498. */
  68499. getRotation(): Vector3;
  68500. /**
  68501. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68502. * @returns true if a cube texture needs to be use
  68503. */
  68504. needCube(): boolean;
  68505. /**
  68506. * Detects if the projection matrix requires to be recomputed this frame.
  68507. * @returns true if it requires to be recomputed otherwise, false.
  68508. */
  68509. needProjectionMatrixCompute(): boolean;
  68510. /**
  68511. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68512. */
  68513. forceProjectionMatrixCompute(): void;
  68514. /** @hidden */
  68515. _initCache(): void;
  68516. /** @hidden */
  68517. _isSynchronized(): boolean;
  68518. /**
  68519. * Computes the world matrix of the node
  68520. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68521. * @returns the world matrix
  68522. */
  68523. computeWorldMatrix(force?: boolean): Matrix;
  68524. /**
  68525. * Gets the minZ used for shadow according to both the scene and the light.
  68526. * @param activeCamera The camera we are returning the min for
  68527. * @returns the depth min z
  68528. */
  68529. getDepthMinZ(activeCamera: Camera): number;
  68530. /**
  68531. * Gets the maxZ used for shadow according to both the scene and the light.
  68532. * @param activeCamera The camera we are returning the max for
  68533. * @returns the depth max z
  68534. */
  68535. getDepthMaxZ(activeCamera: Camera): number;
  68536. /**
  68537. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68538. * @param matrix The materix to updated with the projection information
  68539. * @param viewMatrix The transform matrix of the light
  68540. * @param renderList The list of mesh to render in the map
  68541. * @returns The current light
  68542. */
  68543. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68544. }
  68545. }
  68546. declare module BABYLON {
  68547. /**
  68548. * "Static Class" containing the most commonly used helper while dealing with material for
  68549. * rendering purpose.
  68550. *
  68551. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68552. *
  68553. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68554. */
  68555. export class MaterialHelper {
  68556. /**
  68557. * Bind the current view position to an effect.
  68558. * @param effect The effect to be bound
  68559. * @param scene The scene the eyes position is used from
  68560. */
  68561. static BindEyePosition(effect: Effect, scene: Scene): void;
  68562. /**
  68563. * Helps preparing the defines values about the UVs in used in the effect.
  68564. * UVs are shared as much as we can accross channels in the shaders.
  68565. * @param texture The texture we are preparing the UVs for
  68566. * @param defines The defines to update
  68567. * @param key The channel key "diffuse", "specular"... used in the shader
  68568. */
  68569. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68570. /**
  68571. * Binds a texture matrix value to its corrsponding uniform
  68572. * @param texture The texture to bind the matrix for
  68573. * @param uniformBuffer The uniform buffer receivin the data
  68574. * @param key The channel key "diffuse", "specular"... used in the shader
  68575. */
  68576. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68577. /**
  68578. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68579. * @param mesh defines the current mesh
  68580. * @param scene defines the current scene
  68581. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68582. * @param pointsCloud defines if point cloud rendering has to be turned on
  68583. * @param fogEnabled defines if fog has to be turned on
  68584. * @param alphaTest defines if alpha testing has to be turned on
  68585. * @param defines defines the current list of defines
  68586. */
  68587. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68588. /**
  68589. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68590. * @param scene defines the current scene
  68591. * @param engine defines the current engine
  68592. * @param defines specifies the list of active defines
  68593. * @param useInstances defines if instances have to be turned on
  68594. * @param useClipPlane defines if clip plane have to be turned on
  68595. */
  68596. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68597. /**
  68598. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68599. * @param mesh The mesh containing the geometry data we will draw
  68600. * @param defines The defines to update
  68601. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68602. * @param useBones Precise whether bones should be used or not (override mesh info)
  68603. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68604. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68605. * @returns false if defines are considered not dirty and have not been checked
  68606. */
  68607. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68608. /**
  68609. * Prepares the defines related to multiview
  68610. * @param scene The scene we are intending to draw
  68611. * @param defines The defines to update
  68612. */
  68613. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68614. /**
  68615. * Prepares the defines related to the light information passed in parameter
  68616. * @param scene The scene we are intending to draw
  68617. * @param mesh The mesh the effect is compiling for
  68618. * @param defines The defines to update
  68619. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68620. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68621. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68622. * @returns true if normals will be required for the rest of the effect
  68623. */
  68624. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68625. /**
  68626. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68627. * that won t be acctive due to defines being turned off.
  68628. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68629. * @param samplersList The samplers list
  68630. * @param defines The defines helping in the list generation
  68631. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68632. */
  68633. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68634. /**
  68635. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68636. * @param defines The defines to update while falling back
  68637. * @param fallbacks The authorized effect fallbacks
  68638. * @param maxSimultaneousLights The maximum number of lights allowed
  68639. * @param rank the current rank of the Effect
  68640. * @returns The newly affected rank
  68641. */
  68642. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68643. /**
  68644. * Prepares the list of attributes required for morph targets according to the effect defines.
  68645. * @param attribs The current list of supported attribs
  68646. * @param mesh The mesh to prepare the morph targets attributes for
  68647. * @param defines The current Defines of the effect
  68648. */
  68649. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68650. /**
  68651. * Prepares the list of attributes required for bones according to the effect defines.
  68652. * @param attribs The current list of supported attribs
  68653. * @param mesh The mesh to prepare the bones attributes for
  68654. * @param defines The current Defines of the effect
  68655. * @param fallbacks The current efffect fallback strategy
  68656. */
  68657. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68658. /**
  68659. * Prepares the list of attributes required for instances according to the effect defines.
  68660. * @param attribs The current list of supported attribs
  68661. * @param defines The current Defines of the effect
  68662. */
  68663. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68664. /**
  68665. * Binds the light shadow information to the effect for the given mesh.
  68666. * @param light The light containing the generator
  68667. * @param scene The scene the lights belongs to
  68668. * @param mesh The mesh we are binding the information to render
  68669. * @param lightIndex The light index in the effect used to render the mesh
  68670. * @param effect The effect we are binding the data to
  68671. */
  68672. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68673. /**
  68674. * Binds the light information to the effect.
  68675. * @param light The light containing the generator
  68676. * @param effect The effect we are binding the data to
  68677. * @param lightIndex The light index in the effect used to render
  68678. */
  68679. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68680. /**
  68681. * Binds the lights information from the scene to the effect for the given mesh.
  68682. * @param scene The scene the lights belongs to
  68683. * @param mesh The mesh we are binding the information to render
  68684. * @param effect The effect we are binding the data to
  68685. * @param defines The generated defines for the effect
  68686. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68687. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68688. */
  68689. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68690. private static _tempFogColor;
  68691. /**
  68692. * Binds the fog information from the scene to the effect for the given mesh.
  68693. * @param scene The scene the lights belongs to
  68694. * @param mesh The mesh we are binding the information to render
  68695. * @param effect The effect we are binding the data to
  68696. * @param linearSpace Defines if the fog effect is applied in linear space
  68697. */
  68698. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68699. /**
  68700. * Binds the bones information from the mesh to the effect.
  68701. * @param mesh The mesh we are binding the information to render
  68702. * @param effect The effect we are binding the data to
  68703. */
  68704. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68705. /**
  68706. * Binds the morph targets information from the mesh to the effect.
  68707. * @param abstractMesh The mesh we are binding the information to render
  68708. * @param effect The effect we are binding the data to
  68709. */
  68710. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68711. /**
  68712. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68713. * @param defines The generated defines used in the effect
  68714. * @param effect The effect we are binding the data to
  68715. * @param scene The scene we are willing to render with logarithmic scale for
  68716. */
  68717. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68718. /**
  68719. * Binds the clip plane information from the scene to the effect.
  68720. * @param scene The scene the clip plane information are extracted from
  68721. * @param effect The effect we are binding the data to
  68722. */
  68723. static BindClipPlane(effect: Effect, scene: Scene): void;
  68724. }
  68725. }
  68726. declare module BABYLON {
  68727. /** @hidden */
  68728. export var kernelBlurVaryingDeclaration: {
  68729. name: string;
  68730. shader: string;
  68731. };
  68732. }
  68733. declare module BABYLON {
  68734. /** @hidden */
  68735. export var kernelBlurFragment: {
  68736. name: string;
  68737. shader: string;
  68738. };
  68739. }
  68740. declare module BABYLON {
  68741. /** @hidden */
  68742. export var kernelBlurFragment2: {
  68743. name: string;
  68744. shader: string;
  68745. };
  68746. }
  68747. declare module BABYLON {
  68748. /** @hidden */
  68749. export var kernelBlurPixelShader: {
  68750. name: string;
  68751. shader: string;
  68752. };
  68753. }
  68754. declare module BABYLON {
  68755. /** @hidden */
  68756. export var kernelBlurVertex: {
  68757. name: string;
  68758. shader: string;
  68759. };
  68760. }
  68761. declare module BABYLON {
  68762. /** @hidden */
  68763. export var kernelBlurVertexShader: {
  68764. name: string;
  68765. shader: string;
  68766. };
  68767. }
  68768. declare module BABYLON {
  68769. /**
  68770. * The Blur Post Process which blurs an image based on a kernel and direction.
  68771. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68772. */
  68773. export class BlurPostProcess extends PostProcess {
  68774. /** The direction in which to blur the image. */
  68775. direction: Vector2;
  68776. private blockCompilation;
  68777. protected _kernel: number;
  68778. protected _idealKernel: number;
  68779. protected _packedFloat: boolean;
  68780. private _staticDefines;
  68781. /**
  68782. * Sets the length in pixels of the blur sample region
  68783. */
  68784. /**
  68785. * Gets the length in pixels of the blur sample region
  68786. */
  68787. kernel: number;
  68788. /**
  68789. * Sets wether or not the blur needs to unpack/repack floats
  68790. */
  68791. /**
  68792. * Gets wether or not the blur is unpacking/repacking floats
  68793. */
  68794. packedFloat: boolean;
  68795. /**
  68796. * Creates a new instance BlurPostProcess
  68797. * @param name The name of the effect.
  68798. * @param direction The direction in which to blur the image.
  68799. * @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.
  68800. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68801. * @param camera The camera to apply the render pass to.
  68802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68803. * @param engine The engine which the post process will be applied. (default: current engine)
  68804. * @param reusable If the post process can be reused on the same frame. (default: false)
  68805. * @param textureType Type of textures used when performing the post process. (default: 0)
  68806. * @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)
  68807. */
  68808. constructor(name: string,
  68809. /** The direction in which to blur the image. */
  68810. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68811. /**
  68812. * Updates the effect with the current post process compile time values and recompiles the shader.
  68813. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68814. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68815. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68816. * @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
  68817. * @param onCompiled Called when the shader has been compiled.
  68818. * @param onError Called if there is an error when compiling a shader.
  68819. */
  68820. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68821. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68822. /**
  68823. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68824. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68825. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68826. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68827. * The gaps between physical kernels are compensated for in the weighting of the samples
  68828. * @param idealKernel Ideal blur kernel.
  68829. * @return Nearest best kernel.
  68830. */
  68831. protected _nearestBestKernel(idealKernel: number): number;
  68832. /**
  68833. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68834. * @param x The point on the Gaussian distribution to sample.
  68835. * @return the value of the Gaussian function at x.
  68836. */
  68837. protected _gaussianWeight(x: number): number;
  68838. /**
  68839. * Generates a string that can be used as a floating point number in GLSL.
  68840. * @param x Value to print.
  68841. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68842. * @return GLSL float string.
  68843. */
  68844. protected _glslFloat(x: number, decimalFigures?: number): string;
  68845. }
  68846. }
  68847. declare module BABYLON {
  68848. /** @hidden */
  68849. export var shadowMapPixelShader: {
  68850. name: string;
  68851. shader: string;
  68852. };
  68853. }
  68854. declare module BABYLON {
  68855. /** @hidden */
  68856. export var bonesDeclaration: {
  68857. name: string;
  68858. shader: string;
  68859. };
  68860. }
  68861. declare module BABYLON {
  68862. /** @hidden */
  68863. export var morphTargetsVertexGlobalDeclaration: {
  68864. name: string;
  68865. shader: string;
  68866. };
  68867. }
  68868. declare module BABYLON {
  68869. /** @hidden */
  68870. export var morphTargetsVertexDeclaration: {
  68871. name: string;
  68872. shader: string;
  68873. };
  68874. }
  68875. declare module BABYLON {
  68876. /** @hidden */
  68877. export var instancesDeclaration: {
  68878. name: string;
  68879. shader: string;
  68880. };
  68881. }
  68882. declare module BABYLON {
  68883. /** @hidden */
  68884. export var helperFunctions: {
  68885. name: string;
  68886. shader: string;
  68887. };
  68888. }
  68889. declare module BABYLON {
  68890. /** @hidden */
  68891. export var morphTargetsVertex: {
  68892. name: string;
  68893. shader: string;
  68894. };
  68895. }
  68896. declare module BABYLON {
  68897. /** @hidden */
  68898. export var instancesVertex: {
  68899. name: string;
  68900. shader: string;
  68901. };
  68902. }
  68903. declare module BABYLON {
  68904. /** @hidden */
  68905. export var bonesVertex: {
  68906. name: string;
  68907. shader: string;
  68908. };
  68909. }
  68910. declare module BABYLON {
  68911. /** @hidden */
  68912. export var shadowMapVertexShader: {
  68913. name: string;
  68914. shader: string;
  68915. };
  68916. }
  68917. declare module BABYLON {
  68918. /** @hidden */
  68919. export var depthBoxBlurPixelShader: {
  68920. name: string;
  68921. shader: string;
  68922. };
  68923. }
  68924. declare module BABYLON {
  68925. /**
  68926. * Defines the options associated with the creation of a custom shader for a shadow generator.
  68927. */
  68928. export interface ICustomShaderOptions {
  68929. /**
  68930. * Gets or sets the custom shader name to use
  68931. */
  68932. shaderName: string;
  68933. /**
  68934. * The list of attribute names used in the shader
  68935. */
  68936. attributes?: string[];
  68937. /**
  68938. * The list of unifrom names used in the shader
  68939. */
  68940. uniforms?: string[];
  68941. /**
  68942. * The list of sampler names used in the shader
  68943. */
  68944. samplers?: string[];
  68945. /**
  68946. * The list of defines used in the shader
  68947. */
  68948. defines?: string[];
  68949. }
  68950. /**
  68951. * Interface to implement to create a shadow generator compatible with BJS.
  68952. */
  68953. export interface IShadowGenerator {
  68954. /**
  68955. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  68956. * @returns The render target texture if present otherwise, null
  68957. */
  68958. getShadowMap(): Nullable<RenderTargetTexture>;
  68959. /**
  68960. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  68961. * @returns The render target texture if the shadow map is present otherwise, null
  68962. */
  68963. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  68964. /**
  68965. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  68966. * @param subMesh The submesh we want to render in the shadow map
  68967. * @param useInstances Defines wether will draw in the map using instances
  68968. * @returns true if ready otherwise, false
  68969. */
  68970. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68971. /**
  68972. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  68973. * @param defines Defines of the material we want to update
  68974. * @param lightIndex Index of the light in the enabled light list of the material
  68975. */
  68976. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  68977. /**
  68978. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  68979. * defined in the generator but impacting the effect).
  68980. * It implies the unifroms available on the materials are the standard BJS ones.
  68981. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  68982. * @param effect The effect we are binfing the information for
  68983. */
  68984. bindShadowLight(lightIndex: string, effect: Effect): void;
  68985. /**
  68986. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  68987. * (eq to shadow prjection matrix * light transform matrix)
  68988. * @returns The transform matrix used to create the shadow map
  68989. */
  68990. getTransformMatrix(): Matrix;
  68991. /**
  68992. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  68993. * Cube and 2D textures for instance.
  68994. */
  68995. recreateShadowMap(): void;
  68996. /**
  68997. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  68998. * @param onCompiled Callback triggered at the and of the effects compilation
  68999. * @param options Sets of optional options forcing the compilation with different modes
  69000. */
  69001. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69002. useInstances: boolean;
  69003. }>): void;
  69004. /**
  69005. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69006. * @param options Sets of optional options forcing the compilation with different modes
  69007. * @returns A promise that resolves when the compilation completes
  69008. */
  69009. forceCompilationAsync(options?: Partial<{
  69010. useInstances: boolean;
  69011. }>): Promise<void>;
  69012. /**
  69013. * Serializes the shadow generator setup to a json object.
  69014. * @returns The serialized JSON object
  69015. */
  69016. serialize(): any;
  69017. /**
  69018. * Disposes the Shadow map and related Textures and effects.
  69019. */
  69020. dispose(): void;
  69021. }
  69022. /**
  69023. * Default implementation IShadowGenerator.
  69024. * This is the main object responsible of generating shadows in the framework.
  69025. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69026. */
  69027. export class ShadowGenerator implements IShadowGenerator {
  69028. /**
  69029. * Shadow generator mode None: no filtering applied.
  69030. */
  69031. static readonly FILTER_NONE: number;
  69032. /**
  69033. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69034. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69035. */
  69036. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69037. /**
  69038. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69039. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69040. */
  69041. static readonly FILTER_POISSONSAMPLING: number;
  69042. /**
  69043. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69044. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69045. */
  69046. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69047. /**
  69048. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69049. * edge artifacts on steep falloff.
  69050. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69051. */
  69052. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69053. /**
  69054. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69055. * edge artifacts on steep falloff.
  69056. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69057. */
  69058. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69059. /**
  69060. * Shadow generator mode PCF: Percentage Closer Filtering
  69061. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69062. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69063. */
  69064. static readonly FILTER_PCF: number;
  69065. /**
  69066. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69067. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69068. * Contact Hardening
  69069. */
  69070. static readonly FILTER_PCSS: number;
  69071. /**
  69072. * Reserved for PCF and PCSS
  69073. * Highest Quality.
  69074. *
  69075. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69076. *
  69077. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69078. */
  69079. static readonly QUALITY_HIGH: number;
  69080. /**
  69081. * Reserved for PCF and PCSS
  69082. * Good tradeoff for quality/perf cross devices
  69083. *
  69084. * Execute PCF on a 3*3 kernel.
  69085. *
  69086. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69087. */
  69088. static readonly QUALITY_MEDIUM: number;
  69089. /**
  69090. * Reserved for PCF and PCSS
  69091. * The lowest quality but the fastest.
  69092. *
  69093. * Execute PCF on a 1*1 kernel.
  69094. *
  69095. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69096. */
  69097. static readonly QUALITY_LOW: number;
  69098. /** Gets or sets the custom shader name to use */
  69099. customShaderOptions: ICustomShaderOptions;
  69100. /**
  69101. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69102. */
  69103. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69104. /**
  69105. * Observable triggered before a mesh is rendered in the shadow map.
  69106. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69107. */
  69108. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69109. private _bias;
  69110. /**
  69111. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69112. */
  69113. /**
  69114. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69115. */
  69116. bias: number;
  69117. private _normalBias;
  69118. /**
  69119. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69120. */
  69121. /**
  69122. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69123. */
  69124. normalBias: number;
  69125. private _blurBoxOffset;
  69126. /**
  69127. * Gets the blur box offset: offset applied during the blur pass.
  69128. * Only useful if useKernelBlur = false
  69129. */
  69130. /**
  69131. * Sets the blur box offset: offset applied during the blur pass.
  69132. * Only useful if useKernelBlur = false
  69133. */
  69134. blurBoxOffset: number;
  69135. private _blurScale;
  69136. /**
  69137. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69138. * 2 means half of the size.
  69139. */
  69140. /**
  69141. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69142. * 2 means half of the size.
  69143. */
  69144. blurScale: number;
  69145. private _blurKernel;
  69146. /**
  69147. * Gets the blur kernel: kernel size of the blur pass.
  69148. * Only useful if useKernelBlur = true
  69149. */
  69150. /**
  69151. * Sets the blur kernel: kernel size of the blur pass.
  69152. * Only useful if useKernelBlur = true
  69153. */
  69154. blurKernel: number;
  69155. private _useKernelBlur;
  69156. /**
  69157. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69158. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69159. */
  69160. /**
  69161. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69162. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69163. */
  69164. useKernelBlur: boolean;
  69165. private _depthScale;
  69166. /**
  69167. * Gets the depth scale used in ESM mode.
  69168. */
  69169. /**
  69170. * Sets the depth scale used in ESM mode.
  69171. * This can override the scale stored on the light.
  69172. */
  69173. depthScale: number;
  69174. private _filter;
  69175. /**
  69176. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69177. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69178. */
  69179. /**
  69180. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69181. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69182. */
  69183. filter: number;
  69184. /**
  69185. * Gets if the current filter is set to Poisson Sampling.
  69186. */
  69187. /**
  69188. * Sets the current filter to Poisson Sampling.
  69189. */
  69190. usePoissonSampling: boolean;
  69191. /**
  69192. * Gets if the current filter is set to ESM.
  69193. */
  69194. /**
  69195. * Sets the current filter is to ESM.
  69196. */
  69197. useExponentialShadowMap: boolean;
  69198. /**
  69199. * Gets if the current filter is set to filtered ESM.
  69200. */
  69201. /**
  69202. * Gets if the current filter is set to filtered ESM.
  69203. */
  69204. useBlurExponentialShadowMap: boolean;
  69205. /**
  69206. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69207. * exponential to prevent steep falloff artifacts).
  69208. */
  69209. /**
  69210. * Sets the current filter to "close ESM" (using the inverse of the
  69211. * exponential to prevent steep falloff artifacts).
  69212. */
  69213. useCloseExponentialShadowMap: boolean;
  69214. /**
  69215. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69216. * exponential to prevent steep falloff artifacts).
  69217. */
  69218. /**
  69219. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69220. * exponential to prevent steep falloff artifacts).
  69221. */
  69222. useBlurCloseExponentialShadowMap: boolean;
  69223. /**
  69224. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69225. */
  69226. /**
  69227. * Sets the current filter to "PCF" (percentage closer filtering).
  69228. */
  69229. usePercentageCloserFiltering: boolean;
  69230. private _filteringQuality;
  69231. /**
  69232. * Gets the PCF or PCSS Quality.
  69233. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69234. */
  69235. /**
  69236. * Sets the PCF or PCSS Quality.
  69237. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69238. */
  69239. filteringQuality: number;
  69240. /**
  69241. * Gets if the current filter is set to "PCSS" (contact hardening).
  69242. */
  69243. /**
  69244. * Sets the current filter to "PCSS" (contact hardening).
  69245. */
  69246. useContactHardeningShadow: boolean;
  69247. private _contactHardeningLightSizeUVRatio;
  69248. /**
  69249. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69250. * Using a ratio helps keeping shape stability independently of the map size.
  69251. *
  69252. * It does not account for the light projection as it was having too much
  69253. * instability during the light setup or during light position changes.
  69254. *
  69255. * Only valid if useContactHardeningShadow is true.
  69256. */
  69257. /**
  69258. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69259. * Using a ratio helps keeping shape stability independently of the map size.
  69260. *
  69261. * It does not account for the light projection as it was having too much
  69262. * instability during the light setup or during light position changes.
  69263. *
  69264. * Only valid if useContactHardeningShadow is true.
  69265. */
  69266. contactHardeningLightSizeUVRatio: number;
  69267. private _darkness;
  69268. /**
  69269. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69270. * 0 means strongest and 1 would means no shadow.
  69271. * @returns the darkness.
  69272. */
  69273. getDarkness(): number;
  69274. /**
  69275. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69276. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69277. * @returns the shadow generator allowing fluent coding.
  69278. */
  69279. setDarkness(darkness: number): ShadowGenerator;
  69280. private _transparencyShadow;
  69281. /**
  69282. * Sets the ability to have transparent shadow (boolean).
  69283. * @param transparent True if transparent else False
  69284. * @returns the shadow generator allowing fluent coding
  69285. */
  69286. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69287. private _shadowMap;
  69288. private _shadowMap2;
  69289. /**
  69290. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69291. * @returns The render target texture if present otherwise, null
  69292. */
  69293. getShadowMap(): Nullable<RenderTargetTexture>;
  69294. /**
  69295. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69296. * @returns The render target texture if the shadow map is present otherwise, null
  69297. */
  69298. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69299. /**
  69300. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69301. * @param mesh Mesh to add
  69302. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69303. * @returns the Shadow Generator itself
  69304. */
  69305. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69306. /**
  69307. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69308. * @param mesh Mesh to remove
  69309. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69310. * @returns the Shadow Generator itself
  69311. */
  69312. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69313. /**
  69314. * Controls the extent to which the shadows fade out at the edge of the frustum
  69315. * Used only by directionals and spots
  69316. */
  69317. frustumEdgeFalloff: number;
  69318. private _light;
  69319. /**
  69320. * Returns the associated light object.
  69321. * @returns the light generating the shadow
  69322. */
  69323. getLight(): IShadowLight;
  69324. /**
  69325. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69326. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69327. * It might on the other hand introduce peter panning.
  69328. */
  69329. forceBackFacesOnly: boolean;
  69330. private _scene;
  69331. private _lightDirection;
  69332. private _effect;
  69333. private _viewMatrix;
  69334. private _projectionMatrix;
  69335. private _transformMatrix;
  69336. private _cachedPosition;
  69337. private _cachedDirection;
  69338. private _cachedDefines;
  69339. private _currentRenderID;
  69340. private _boxBlurPostprocess;
  69341. private _kernelBlurXPostprocess;
  69342. private _kernelBlurYPostprocess;
  69343. private _blurPostProcesses;
  69344. private _mapSize;
  69345. private _currentFaceIndex;
  69346. private _currentFaceIndexCache;
  69347. private _textureType;
  69348. private _defaultTextureMatrix;
  69349. /** @hidden */
  69350. static _SceneComponentInitialization: (scene: Scene) => void;
  69351. /**
  69352. * Creates a ShadowGenerator object.
  69353. * A ShadowGenerator is the required tool to use the shadows.
  69354. * Each light casting shadows needs to use its own ShadowGenerator.
  69355. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69356. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69357. * @param light The light object generating the shadows.
  69358. * @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.
  69359. */
  69360. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69361. private _initializeGenerator;
  69362. private _initializeShadowMap;
  69363. private _initializeBlurRTTAndPostProcesses;
  69364. private _renderForShadowMap;
  69365. private _renderSubMeshForShadowMap;
  69366. private _applyFilterValues;
  69367. /**
  69368. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69369. * @param onCompiled Callback triggered at the and of the effects compilation
  69370. * @param options Sets of optional options forcing the compilation with different modes
  69371. */
  69372. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69373. useInstances: boolean;
  69374. }>): void;
  69375. /**
  69376. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69377. * @param options Sets of optional options forcing the compilation with different modes
  69378. * @returns A promise that resolves when the compilation completes
  69379. */
  69380. forceCompilationAsync(options?: Partial<{
  69381. useInstances: boolean;
  69382. }>): Promise<void>;
  69383. /**
  69384. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69385. * @param subMesh The submesh we want to render in the shadow map
  69386. * @param useInstances Defines wether will draw in the map using instances
  69387. * @returns true if ready otherwise, false
  69388. */
  69389. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69390. /**
  69391. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69392. * @param defines Defines of the material we want to update
  69393. * @param lightIndex Index of the light in the enabled light list of the material
  69394. */
  69395. prepareDefines(defines: any, lightIndex: number): void;
  69396. /**
  69397. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69398. * defined in the generator but impacting the effect).
  69399. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69400. * @param effect The effect we are binfing the information for
  69401. */
  69402. bindShadowLight(lightIndex: string, effect: Effect): void;
  69403. /**
  69404. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69405. * (eq to shadow prjection matrix * light transform matrix)
  69406. * @returns The transform matrix used to create the shadow map
  69407. */
  69408. getTransformMatrix(): Matrix;
  69409. /**
  69410. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69411. * Cube and 2D textures for instance.
  69412. */
  69413. recreateShadowMap(): void;
  69414. private _disposeBlurPostProcesses;
  69415. private _disposeRTTandPostProcesses;
  69416. /**
  69417. * Disposes the ShadowGenerator.
  69418. * Returns nothing.
  69419. */
  69420. dispose(): void;
  69421. /**
  69422. * Serializes the shadow generator setup to a json object.
  69423. * @returns The serialized JSON object
  69424. */
  69425. serialize(): any;
  69426. /**
  69427. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69428. * @param parsedShadowGenerator The JSON object to parse
  69429. * @param scene The scene to create the shadow map for
  69430. * @returns The parsed shadow generator
  69431. */
  69432. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69433. }
  69434. }
  69435. declare module BABYLON {
  69436. /**
  69437. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69438. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69439. * 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.
  69440. */
  69441. export abstract class Light extends Node {
  69442. /**
  69443. * Falloff Default: light is falling off following the material specification:
  69444. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69445. */
  69446. static readonly FALLOFF_DEFAULT: number;
  69447. /**
  69448. * Falloff Physical: light is falling off following the inverse squared distance law.
  69449. */
  69450. static readonly FALLOFF_PHYSICAL: number;
  69451. /**
  69452. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69453. * to enhance interoperability with other engines.
  69454. */
  69455. static readonly FALLOFF_GLTF: number;
  69456. /**
  69457. * Falloff Standard: light is falling off like in the standard material
  69458. * to enhance interoperability with other materials.
  69459. */
  69460. static readonly FALLOFF_STANDARD: number;
  69461. /**
  69462. * If every light affecting the material is in this lightmapMode,
  69463. * material.lightmapTexture adds or multiplies
  69464. * (depends on material.useLightmapAsShadowmap)
  69465. * after every other light calculations.
  69466. */
  69467. static readonly LIGHTMAP_DEFAULT: number;
  69468. /**
  69469. * material.lightmapTexture as only diffuse lighting from this light
  69470. * adds only specular lighting from this light
  69471. * adds dynamic shadows
  69472. */
  69473. static readonly LIGHTMAP_SPECULAR: number;
  69474. /**
  69475. * material.lightmapTexture as only lighting
  69476. * no light calculation from this light
  69477. * only adds dynamic shadows from this light
  69478. */
  69479. static readonly LIGHTMAP_SHADOWSONLY: number;
  69480. /**
  69481. * Each light type uses the default quantity according to its type:
  69482. * point/spot lights use luminous intensity
  69483. * directional lights use illuminance
  69484. */
  69485. static readonly INTENSITYMODE_AUTOMATIC: number;
  69486. /**
  69487. * lumen (lm)
  69488. */
  69489. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69490. /**
  69491. * candela (lm/sr)
  69492. */
  69493. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69494. /**
  69495. * lux (lm/m^2)
  69496. */
  69497. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69498. /**
  69499. * nit (cd/m^2)
  69500. */
  69501. static readonly INTENSITYMODE_LUMINANCE: number;
  69502. /**
  69503. * Light type const id of the point light.
  69504. */
  69505. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69506. /**
  69507. * Light type const id of the directional light.
  69508. */
  69509. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69510. /**
  69511. * Light type const id of the spot light.
  69512. */
  69513. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69514. /**
  69515. * Light type const id of the hemispheric light.
  69516. */
  69517. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69518. /**
  69519. * Diffuse gives the basic color to an object.
  69520. */
  69521. diffuse: Color3;
  69522. /**
  69523. * Specular produces a highlight color on an object.
  69524. * Note: This is note affecting PBR materials.
  69525. */
  69526. specular: Color3;
  69527. /**
  69528. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69529. * falling off base on range or angle.
  69530. * This can be set to any values in Light.FALLOFF_x.
  69531. *
  69532. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69533. * other types of materials.
  69534. */
  69535. falloffType: number;
  69536. /**
  69537. * Strength of the light.
  69538. * Note: By default it is define in the framework own unit.
  69539. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69540. */
  69541. intensity: number;
  69542. private _range;
  69543. protected _inverseSquaredRange: number;
  69544. /**
  69545. * Defines how far from the source the light is impacting in scene units.
  69546. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69547. */
  69548. /**
  69549. * Defines how far from the source the light is impacting in scene units.
  69550. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69551. */
  69552. range: number;
  69553. /**
  69554. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69555. * of light.
  69556. */
  69557. private _photometricScale;
  69558. private _intensityMode;
  69559. /**
  69560. * Gets the photometric scale used to interpret the intensity.
  69561. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69562. */
  69563. /**
  69564. * Sets the photometric scale used to interpret the intensity.
  69565. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69566. */
  69567. intensityMode: number;
  69568. private _radius;
  69569. /**
  69570. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69571. */
  69572. /**
  69573. * sets the light radius used by PBR Materials to simulate soft area lights.
  69574. */
  69575. radius: number;
  69576. private _renderPriority;
  69577. /**
  69578. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69579. * exceeding the number allowed of the materials.
  69580. */
  69581. renderPriority: number;
  69582. private _shadowEnabled;
  69583. /**
  69584. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69585. * the current shadow generator.
  69586. */
  69587. /**
  69588. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69589. * the current shadow generator.
  69590. */
  69591. shadowEnabled: boolean;
  69592. private _includedOnlyMeshes;
  69593. /**
  69594. * Gets the only meshes impacted by this light.
  69595. */
  69596. /**
  69597. * Sets the only meshes impacted by this light.
  69598. */
  69599. includedOnlyMeshes: AbstractMesh[];
  69600. private _excludedMeshes;
  69601. /**
  69602. * Gets the meshes not impacted by this light.
  69603. */
  69604. /**
  69605. * Sets the meshes not impacted by this light.
  69606. */
  69607. excludedMeshes: AbstractMesh[];
  69608. private _excludeWithLayerMask;
  69609. /**
  69610. * Gets the layer id use to find what meshes are not impacted by the light.
  69611. * Inactive if 0
  69612. */
  69613. /**
  69614. * Sets the layer id use to find what meshes are not impacted by the light.
  69615. * Inactive if 0
  69616. */
  69617. excludeWithLayerMask: number;
  69618. private _includeOnlyWithLayerMask;
  69619. /**
  69620. * Gets the layer id use to find what meshes are impacted by the light.
  69621. * Inactive if 0
  69622. */
  69623. /**
  69624. * Sets the layer id use to find what meshes are impacted by the light.
  69625. * Inactive if 0
  69626. */
  69627. includeOnlyWithLayerMask: number;
  69628. private _lightmapMode;
  69629. /**
  69630. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69631. */
  69632. /**
  69633. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69634. */
  69635. lightmapMode: number;
  69636. /**
  69637. * Shadow generator associted to the light.
  69638. * @hidden Internal use only.
  69639. */
  69640. _shadowGenerator: Nullable<IShadowGenerator>;
  69641. /**
  69642. * @hidden Internal use only.
  69643. */
  69644. _excludedMeshesIds: string[];
  69645. /**
  69646. * @hidden Internal use only.
  69647. */
  69648. _includedOnlyMeshesIds: string[];
  69649. /**
  69650. * The current light unifom buffer.
  69651. * @hidden Internal use only.
  69652. */
  69653. _uniformBuffer: UniformBuffer;
  69654. /**
  69655. * Creates a Light object in the scene.
  69656. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69657. * @param name The firendly name of the light
  69658. * @param scene The scene the light belongs too
  69659. */
  69660. constructor(name: string, scene: Scene);
  69661. protected abstract _buildUniformLayout(): void;
  69662. /**
  69663. * Sets the passed Effect "effect" with the Light information.
  69664. * @param effect The effect to update
  69665. * @param lightIndex The index of the light in the effect to update
  69666. * @returns The light
  69667. */
  69668. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69669. /**
  69670. * Returns the string "Light".
  69671. * @returns the class name
  69672. */
  69673. getClassName(): string;
  69674. /** @hidden */
  69675. readonly _isLight: boolean;
  69676. /**
  69677. * Converts the light information to a readable string for debug purpose.
  69678. * @param fullDetails Supports for multiple levels of logging within scene loading
  69679. * @returns the human readable light info
  69680. */
  69681. toString(fullDetails?: boolean): string;
  69682. /** @hidden */
  69683. protected _syncParentEnabledState(): void;
  69684. /**
  69685. * Set the enabled state of this node.
  69686. * @param value - the new enabled state
  69687. */
  69688. setEnabled(value: boolean): void;
  69689. /**
  69690. * Returns the Light associated shadow generator if any.
  69691. * @return the associated shadow generator.
  69692. */
  69693. getShadowGenerator(): Nullable<IShadowGenerator>;
  69694. /**
  69695. * Returns a Vector3, the absolute light position in the World.
  69696. * @returns the world space position of the light
  69697. */
  69698. getAbsolutePosition(): Vector3;
  69699. /**
  69700. * Specifies if the light will affect the passed mesh.
  69701. * @param mesh The mesh to test against the light
  69702. * @return true the mesh is affected otherwise, false.
  69703. */
  69704. canAffectMesh(mesh: AbstractMesh): boolean;
  69705. /**
  69706. * Sort function to order lights for rendering.
  69707. * @param a First Light object to compare to second.
  69708. * @param b Second Light object to compare first.
  69709. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69710. */
  69711. static CompareLightsPriority(a: Light, b: Light): number;
  69712. /**
  69713. * Releases resources associated with this node.
  69714. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69715. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69716. */
  69717. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69718. /**
  69719. * Returns the light type ID (integer).
  69720. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69721. */
  69722. getTypeID(): number;
  69723. /**
  69724. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69725. * @returns the scaled intensity in intensity mode unit
  69726. */
  69727. getScaledIntensity(): number;
  69728. /**
  69729. * Returns a new Light object, named "name", from the current one.
  69730. * @param name The name of the cloned light
  69731. * @returns the new created light
  69732. */
  69733. clone(name: string): Nullable<Light>;
  69734. /**
  69735. * Serializes the current light into a Serialization object.
  69736. * @returns the serialized object.
  69737. */
  69738. serialize(): any;
  69739. /**
  69740. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69741. * This new light is named "name" and added to the passed scene.
  69742. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69743. * @param name The friendly name of the light
  69744. * @param scene The scene the new light will belong to
  69745. * @returns the constructor function
  69746. */
  69747. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69748. /**
  69749. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69750. * @param parsedLight The JSON representation of the light
  69751. * @param scene The scene to create the parsed light in
  69752. * @returns the created light after parsing
  69753. */
  69754. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69755. private _hookArrayForExcluded;
  69756. private _hookArrayForIncludedOnly;
  69757. private _resyncMeshes;
  69758. /**
  69759. * Forces the meshes to update their light related information in their rendering used effects
  69760. * @hidden Internal Use Only
  69761. */
  69762. _markMeshesAsLightDirty(): void;
  69763. /**
  69764. * Recomputes the cached photometric scale if needed.
  69765. */
  69766. private _computePhotometricScale;
  69767. /**
  69768. * Returns the Photometric Scale according to the light type and intensity mode.
  69769. */
  69770. private _getPhotometricScale;
  69771. /**
  69772. * Reorder the light in the scene according to their defined priority.
  69773. * @hidden Internal Use Only
  69774. */
  69775. _reorderLightsInScene(): void;
  69776. /**
  69777. * Prepares the list of defines specific to the light type.
  69778. * @param defines the list of defines
  69779. * @param lightIndex defines the index of the light for the effect
  69780. */
  69781. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69782. }
  69783. }
  69784. declare module BABYLON {
  69785. /**
  69786. * Interface used to define Action
  69787. */
  69788. export interface IAction {
  69789. /**
  69790. * Trigger for the action
  69791. */
  69792. trigger: number;
  69793. /** Options of the trigger */
  69794. triggerOptions: any;
  69795. /**
  69796. * Gets the trigger parameters
  69797. * @returns the trigger parameters
  69798. */
  69799. getTriggerParameter(): any;
  69800. /**
  69801. * Internal only - executes current action event
  69802. * @hidden
  69803. */
  69804. _executeCurrent(evt?: ActionEvent): void;
  69805. /**
  69806. * Serialize placeholder for child classes
  69807. * @param parent of child
  69808. * @returns the serialized object
  69809. */
  69810. serialize(parent: any): any;
  69811. /**
  69812. * Internal only
  69813. * @hidden
  69814. */
  69815. _prepare(): void;
  69816. /**
  69817. * Internal only - manager for action
  69818. * @hidden
  69819. */
  69820. _actionManager: AbstractActionManager;
  69821. }
  69822. /**
  69823. * The action to be carried out following a trigger
  69824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69825. */
  69826. export class Action implements IAction {
  69827. /** the trigger, with or without parameters, for the action */
  69828. triggerOptions: any;
  69829. /**
  69830. * Trigger for the action
  69831. */
  69832. trigger: number;
  69833. /**
  69834. * Internal only - manager for action
  69835. * @hidden
  69836. */
  69837. _actionManager: ActionManager;
  69838. private _nextActiveAction;
  69839. private _child;
  69840. private _condition?;
  69841. private _triggerParameter;
  69842. /**
  69843. * An event triggered prior to action being executed.
  69844. */
  69845. onBeforeExecuteObservable: Observable<Action>;
  69846. /**
  69847. * Creates a new Action
  69848. * @param triggerOptions the trigger, with or without parameters, for the action
  69849. * @param condition an optional determinant of action
  69850. */
  69851. constructor(
  69852. /** the trigger, with or without parameters, for the action */
  69853. triggerOptions: any, condition?: Condition);
  69854. /**
  69855. * Internal only
  69856. * @hidden
  69857. */
  69858. _prepare(): void;
  69859. /**
  69860. * Gets the trigger parameters
  69861. * @returns the trigger parameters
  69862. */
  69863. getTriggerParameter(): any;
  69864. /**
  69865. * Internal only - executes current action event
  69866. * @hidden
  69867. */
  69868. _executeCurrent(evt?: ActionEvent): void;
  69869. /**
  69870. * Execute placeholder for child classes
  69871. * @param evt optional action event
  69872. */
  69873. execute(evt?: ActionEvent): void;
  69874. /**
  69875. * Skips to next active action
  69876. */
  69877. skipToNextActiveAction(): void;
  69878. /**
  69879. * Adds action to chain of actions, may be a DoNothingAction
  69880. * @param action defines the next action to execute
  69881. * @returns The action passed in
  69882. * @see https://www.babylonjs-playground.com/#1T30HR#0
  69883. */
  69884. then(action: Action): Action;
  69885. /**
  69886. * Internal only
  69887. * @hidden
  69888. */
  69889. _getProperty(propertyPath: string): string;
  69890. /**
  69891. * Internal only
  69892. * @hidden
  69893. */
  69894. _getEffectiveTarget(target: any, propertyPath: string): any;
  69895. /**
  69896. * Serialize placeholder for child classes
  69897. * @param parent of child
  69898. * @returns the serialized object
  69899. */
  69900. serialize(parent: any): any;
  69901. /**
  69902. * Internal only called by serialize
  69903. * @hidden
  69904. */
  69905. protected _serialize(serializedAction: any, parent?: any): any;
  69906. /**
  69907. * Internal only
  69908. * @hidden
  69909. */
  69910. static _SerializeValueAsString: (value: any) => string;
  69911. /**
  69912. * Internal only
  69913. * @hidden
  69914. */
  69915. static _GetTargetProperty: (target: Scene | Node) => {
  69916. name: string;
  69917. targetType: string;
  69918. value: string;
  69919. };
  69920. }
  69921. }
  69922. declare module BABYLON {
  69923. /**
  69924. * A Condition applied to an Action
  69925. */
  69926. export class Condition {
  69927. /**
  69928. * Internal only - manager for action
  69929. * @hidden
  69930. */
  69931. _actionManager: ActionManager;
  69932. /**
  69933. * Internal only
  69934. * @hidden
  69935. */
  69936. _evaluationId: number;
  69937. /**
  69938. * Internal only
  69939. * @hidden
  69940. */
  69941. _currentResult: boolean;
  69942. /**
  69943. * Creates a new Condition
  69944. * @param actionManager the manager of the action the condition is applied to
  69945. */
  69946. constructor(actionManager: ActionManager);
  69947. /**
  69948. * Check if the current condition is valid
  69949. * @returns a boolean
  69950. */
  69951. isValid(): boolean;
  69952. /**
  69953. * Internal only
  69954. * @hidden
  69955. */
  69956. _getProperty(propertyPath: string): string;
  69957. /**
  69958. * Internal only
  69959. * @hidden
  69960. */
  69961. _getEffectiveTarget(target: any, propertyPath: string): any;
  69962. /**
  69963. * Serialize placeholder for child classes
  69964. * @returns the serialized object
  69965. */
  69966. serialize(): any;
  69967. /**
  69968. * Internal only
  69969. * @hidden
  69970. */
  69971. protected _serialize(serializedCondition: any): any;
  69972. }
  69973. /**
  69974. * Defines specific conditional operators as extensions of Condition
  69975. */
  69976. export class ValueCondition extends Condition {
  69977. /** path to specify the property of the target the conditional operator uses */
  69978. propertyPath: string;
  69979. /** the value compared by the conditional operator against the current value of the property */
  69980. value: any;
  69981. /** the conditional operator, default ValueCondition.IsEqual */
  69982. operator: number;
  69983. /**
  69984. * Internal only
  69985. * @hidden
  69986. */
  69987. private static _IsEqual;
  69988. /**
  69989. * Internal only
  69990. * @hidden
  69991. */
  69992. private static _IsDifferent;
  69993. /**
  69994. * Internal only
  69995. * @hidden
  69996. */
  69997. private static _IsGreater;
  69998. /**
  69999. * Internal only
  70000. * @hidden
  70001. */
  70002. private static _IsLesser;
  70003. /**
  70004. * returns the number for IsEqual
  70005. */
  70006. static readonly IsEqual: number;
  70007. /**
  70008. * Returns the number for IsDifferent
  70009. */
  70010. static readonly IsDifferent: number;
  70011. /**
  70012. * Returns the number for IsGreater
  70013. */
  70014. static readonly IsGreater: number;
  70015. /**
  70016. * Returns the number for IsLesser
  70017. */
  70018. static readonly IsLesser: number;
  70019. /**
  70020. * Internal only The action manager for the condition
  70021. * @hidden
  70022. */
  70023. _actionManager: ActionManager;
  70024. /**
  70025. * Internal only
  70026. * @hidden
  70027. */
  70028. private _target;
  70029. /**
  70030. * Internal only
  70031. * @hidden
  70032. */
  70033. private _effectiveTarget;
  70034. /**
  70035. * Internal only
  70036. * @hidden
  70037. */
  70038. private _property;
  70039. /**
  70040. * Creates a new ValueCondition
  70041. * @param actionManager manager for the action the condition applies to
  70042. * @param target for the action
  70043. * @param propertyPath path to specify the property of the target the conditional operator uses
  70044. * @param value the value compared by the conditional operator against the current value of the property
  70045. * @param operator the conditional operator, default ValueCondition.IsEqual
  70046. */
  70047. constructor(actionManager: ActionManager, target: any,
  70048. /** path to specify the property of the target the conditional operator uses */
  70049. propertyPath: string,
  70050. /** the value compared by the conditional operator against the current value of the property */
  70051. value: any,
  70052. /** the conditional operator, default ValueCondition.IsEqual */
  70053. operator?: number);
  70054. /**
  70055. * Compares the given value with the property value for the specified conditional operator
  70056. * @returns the result of the comparison
  70057. */
  70058. isValid(): boolean;
  70059. /**
  70060. * Serialize the ValueCondition into a JSON compatible object
  70061. * @returns serialization object
  70062. */
  70063. serialize(): any;
  70064. /**
  70065. * Gets the name of the conditional operator for the ValueCondition
  70066. * @param operator the conditional operator
  70067. * @returns the name
  70068. */
  70069. static GetOperatorName(operator: number): string;
  70070. }
  70071. /**
  70072. * Defines a predicate condition as an extension of Condition
  70073. */
  70074. export class PredicateCondition extends Condition {
  70075. /** defines the predicate function used to validate the condition */
  70076. predicate: () => boolean;
  70077. /**
  70078. * Internal only - manager for action
  70079. * @hidden
  70080. */
  70081. _actionManager: ActionManager;
  70082. /**
  70083. * Creates a new PredicateCondition
  70084. * @param actionManager manager for the action the condition applies to
  70085. * @param predicate defines the predicate function used to validate the condition
  70086. */
  70087. constructor(actionManager: ActionManager,
  70088. /** defines the predicate function used to validate the condition */
  70089. predicate: () => boolean);
  70090. /**
  70091. * @returns the validity of the predicate condition
  70092. */
  70093. isValid(): boolean;
  70094. }
  70095. /**
  70096. * Defines a state condition as an extension of Condition
  70097. */
  70098. export class StateCondition extends Condition {
  70099. /** Value to compare with target state */
  70100. value: string;
  70101. /**
  70102. * Internal only - manager for action
  70103. * @hidden
  70104. */
  70105. _actionManager: ActionManager;
  70106. /**
  70107. * Internal only
  70108. * @hidden
  70109. */
  70110. private _target;
  70111. /**
  70112. * Creates a new StateCondition
  70113. * @param actionManager manager for the action the condition applies to
  70114. * @param target of the condition
  70115. * @param value to compare with target state
  70116. */
  70117. constructor(actionManager: ActionManager, target: any,
  70118. /** Value to compare with target state */
  70119. value: string);
  70120. /**
  70121. * Gets a boolean indicating if the current condition is met
  70122. * @returns the validity of the state
  70123. */
  70124. isValid(): boolean;
  70125. /**
  70126. * Serialize the StateCondition into a JSON compatible object
  70127. * @returns serialization object
  70128. */
  70129. serialize(): any;
  70130. }
  70131. }
  70132. declare module BABYLON {
  70133. /**
  70134. * This defines an action responsible to toggle a boolean once triggered.
  70135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70136. */
  70137. export class SwitchBooleanAction extends Action {
  70138. /**
  70139. * The path to the boolean property in the target object
  70140. */
  70141. propertyPath: string;
  70142. private _target;
  70143. private _effectiveTarget;
  70144. private _property;
  70145. /**
  70146. * Instantiate the action
  70147. * @param triggerOptions defines the trigger options
  70148. * @param target defines the object containing the boolean
  70149. * @param propertyPath defines the path to the boolean property in the target object
  70150. * @param condition defines the trigger related conditions
  70151. */
  70152. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70153. /** @hidden */
  70154. _prepare(): void;
  70155. /**
  70156. * Execute the action toggle the boolean value.
  70157. */
  70158. execute(): void;
  70159. /**
  70160. * Serializes the actions and its related information.
  70161. * @param parent defines the object to serialize in
  70162. * @returns the serialized object
  70163. */
  70164. serialize(parent: any): any;
  70165. }
  70166. /**
  70167. * This defines an action responsible to set a the state field of the target
  70168. * to a desired value once triggered.
  70169. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70170. */
  70171. export class SetStateAction extends Action {
  70172. /**
  70173. * The value to store in the state field.
  70174. */
  70175. value: string;
  70176. private _target;
  70177. /**
  70178. * Instantiate the action
  70179. * @param triggerOptions defines the trigger options
  70180. * @param target defines the object containing the state property
  70181. * @param value defines the value to store in the state field
  70182. * @param condition defines the trigger related conditions
  70183. */
  70184. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70185. /**
  70186. * Execute the action and store the value on the target state property.
  70187. */
  70188. execute(): void;
  70189. /**
  70190. * Serializes the actions and its related information.
  70191. * @param parent defines the object to serialize in
  70192. * @returns the serialized object
  70193. */
  70194. serialize(parent: any): any;
  70195. }
  70196. /**
  70197. * This defines an action responsible to set a property of the target
  70198. * to a desired value once triggered.
  70199. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70200. */
  70201. export class SetValueAction extends Action {
  70202. /**
  70203. * The path of the property to set in the target.
  70204. */
  70205. propertyPath: string;
  70206. /**
  70207. * The value to set in the property
  70208. */
  70209. value: any;
  70210. private _target;
  70211. private _effectiveTarget;
  70212. private _property;
  70213. /**
  70214. * Instantiate the action
  70215. * @param triggerOptions defines the trigger options
  70216. * @param target defines the object containing the property
  70217. * @param propertyPath defines the path of the property to set in the target
  70218. * @param value defines the value to set in the property
  70219. * @param condition defines the trigger related conditions
  70220. */
  70221. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70222. /** @hidden */
  70223. _prepare(): void;
  70224. /**
  70225. * Execute the action and set the targetted property to the desired value.
  70226. */
  70227. execute(): void;
  70228. /**
  70229. * Serializes the actions and its related information.
  70230. * @param parent defines the object to serialize in
  70231. * @returns the serialized object
  70232. */
  70233. serialize(parent: any): any;
  70234. }
  70235. /**
  70236. * This defines an action responsible to increment the target value
  70237. * to a desired value once triggered.
  70238. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70239. */
  70240. export class IncrementValueAction extends Action {
  70241. /**
  70242. * The path of the property to increment in the target.
  70243. */
  70244. propertyPath: string;
  70245. /**
  70246. * The value we should increment the property by.
  70247. */
  70248. value: any;
  70249. private _target;
  70250. private _effectiveTarget;
  70251. private _property;
  70252. /**
  70253. * Instantiate the action
  70254. * @param triggerOptions defines the trigger options
  70255. * @param target defines the object containing the property
  70256. * @param propertyPath defines the path of the property to increment in the target
  70257. * @param value defines the value value we should increment the property by
  70258. * @param condition defines the trigger related conditions
  70259. */
  70260. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70261. /** @hidden */
  70262. _prepare(): void;
  70263. /**
  70264. * Execute the action and increment the target of the value amount.
  70265. */
  70266. execute(): void;
  70267. /**
  70268. * Serializes the actions and its related information.
  70269. * @param parent defines the object to serialize in
  70270. * @returns the serialized object
  70271. */
  70272. serialize(parent: any): any;
  70273. }
  70274. /**
  70275. * This defines an action responsible to start an animation once triggered.
  70276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70277. */
  70278. export class PlayAnimationAction extends Action {
  70279. /**
  70280. * Where the animation should start (animation frame)
  70281. */
  70282. from: number;
  70283. /**
  70284. * Where the animation should stop (animation frame)
  70285. */
  70286. to: number;
  70287. /**
  70288. * Define if the animation should loop or stop after the first play.
  70289. */
  70290. loop?: boolean;
  70291. private _target;
  70292. /**
  70293. * Instantiate the action
  70294. * @param triggerOptions defines the trigger options
  70295. * @param target defines the target animation or animation name
  70296. * @param from defines from where the animation should start (animation frame)
  70297. * @param end defines where the animation should stop (animation frame)
  70298. * @param loop defines if the animation should loop or stop after the first play
  70299. * @param condition defines the trigger related conditions
  70300. */
  70301. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70302. /** @hidden */
  70303. _prepare(): void;
  70304. /**
  70305. * Execute the action and play the animation.
  70306. */
  70307. execute(): void;
  70308. /**
  70309. * Serializes the actions and its related information.
  70310. * @param parent defines the object to serialize in
  70311. * @returns the serialized object
  70312. */
  70313. serialize(parent: any): any;
  70314. }
  70315. /**
  70316. * This defines an action responsible to stop an animation once triggered.
  70317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70318. */
  70319. export class StopAnimationAction extends Action {
  70320. private _target;
  70321. /**
  70322. * Instantiate the action
  70323. * @param triggerOptions defines the trigger options
  70324. * @param target defines the target animation or animation name
  70325. * @param condition defines the trigger related conditions
  70326. */
  70327. constructor(triggerOptions: any, target: any, condition?: Condition);
  70328. /** @hidden */
  70329. _prepare(): void;
  70330. /**
  70331. * Execute the action and stop the animation.
  70332. */
  70333. execute(): void;
  70334. /**
  70335. * Serializes the actions and its related information.
  70336. * @param parent defines the object to serialize in
  70337. * @returns the serialized object
  70338. */
  70339. serialize(parent: any): any;
  70340. }
  70341. /**
  70342. * This defines an action responsible that does nothing once triggered.
  70343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70344. */
  70345. export class DoNothingAction extends Action {
  70346. /**
  70347. * Instantiate the action
  70348. * @param triggerOptions defines the trigger options
  70349. * @param condition defines the trigger related conditions
  70350. */
  70351. constructor(triggerOptions?: any, condition?: Condition);
  70352. /**
  70353. * Execute the action and do nothing.
  70354. */
  70355. execute(): void;
  70356. /**
  70357. * Serializes the actions and its related information.
  70358. * @param parent defines the object to serialize in
  70359. * @returns the serialized object
  70360. */
  70361. serialize(parent: any): any;
  70362. }
  70363. /**
  70364. * This defines an action responsible to trigger several actions once triggered.
  70365. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70366. */
  70367. export class CombineAction extends Action {
  70368. /**
  70369. * The list of aggregated animations to run.
  70370. */
  70371. children: Action[];
  70372. /**
  70373. * Instantiate the action
  70374. * @param triggerOptions defines the trigger options
  70375. * @param children defines the list of aggregated animations to run
  70376. * @param condition defines the trigger related conditions
  70377. */
  70378. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70379. /** @hidden */
  70380. _prepare(): void;
  70381. /**
  70382. * Execute the action and executes all the aggregated actions.
  70383. */
  70384. execute(evt: ActionEvent): void;
  70385. /**
  70386. * Serializes the actions and its related information.
  70387. * @param parent defines the object to serialize in
  70388. * @returns the serialized object
  70389. */
  70390. serialize(parent: any): any;
  70391. }
  70392. /**
  70393. * This defines an action responsible to run code (external event) once triggered.
  70394. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70395. */
  70396. export class ExecuteCodeAction extends Action {
  70397. /**
  70398. * The callback function to run.
  70399. */
  70400. func: (evt: ActionEvent) => void;
  70401. /**
  70402. * Instantiate the action
  70403. * @param triggerOptions defines the trigger options
  70404. * @param func defines the callback function to run
  70405. * @param condition defines the trigger related conditions
  70406. */
  70407. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70408. /**
  70409. * Execute the action and run the attached code.
  70410. */
  70411. execute(evt: ActionEvent): void;
  70412. }
  70413. /**
  70414. * This defines an action responsible to set the parent property of the target once triggered.
  70415. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70416. */
  70417. export class SetParentAction extends Action {
  70418. private _parent;
  70419. private _target;
  70420. /**
  70421. * Instantiate the action
  70422. * @param triggerOptions defines the trigger options
  70423. * @param target defines the target containing the parent property
  70424. * @param parent defines from where the animation should start (animation frame)
  70425. * @param condition defines the trigger related conditions
  70426. */
  70427. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70428. /** @hidden */
  70429. _prepare(): void;
  70430. /**
  70431. * Execute the action and set the parent property.
  70432. */
  70433. execute(): void;
  70434. /**
  70435. * Serializes the actions and its related information.
  70436. * @param parent defines the object to serialize in
  70437. * @returns the serialized object
  70438. */
  70439. serialize(parent: any): any;
  70440. }
  70441. }
  70442. declare module BABYLON {
  70443. /**
  70444. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70445. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70446. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70447. */
  70448. export class ActionManager extends AbstractActionManager {
  70449. /**
  70450. * Nothing
  70451. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70452. */
  70453. static readonly NothingTrigger: number;
  70454. /**
  70455. * On pick
  70456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70457. */
  70458. static readonly OnPickTrigger: number;
  70459. /**
  70460. * On left pick
  70461. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70462. */
  70463. static readonly OnLeftPickTrigger: number;
  70464. /**
  70465. * On right pick
  70466. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70467. */
  70468. static readonly OnRightPickTrigger: number;
  70469. /**
  70470. * On center pick
  70471. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70472. */
  70473. static readonly OnCenterPickTrigger: number;
  70474. /**
  70475. * On pick down
  70476. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70477. */
  70478. static readonly OnPickDownTrigger: number;
  70479. /**
  70480. * On double pick
  70481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70482. */
  70483. static readonly OnDoublePickTrigger: number;
  70484. /**
  70485. * On pick up
  70486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70487. */
  70488. static readonly OnPickUpTrigger: number;
  70489. /**
  70490. * On pick out.
  70491. * This trigger will only be raised if you also declared a OnPickDown
  70492. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70493. */
  70494. static readonly OnPickOutTrigger: number;
  70495. /**
  70496. * On long press
  70497. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70498. */
  70499. static readonly OnLongPressTrigger: number;
  70500. /**
  70501. * On pointer over
  70502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70503. */
  70504. static readonly OnPointerOverTrigger: number;
  70505. /**
  70506. * On pointer out
  70507. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70508. */
  70509. static readonly OnPointerOutTrigger: number;
  70510. /**
  70511. * On every frame
  70512. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70513. */
  70514. static readonly OnEveryFrameTrigger: number;
  70515. /**
  70516. * On intersection enter
  70517. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70518. */
  70519. static readonly OnIntersectionEnterTrigger: number;
  70520. /**
  70521. * On intersection exit
  70522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70523. */
  70524. static readonly OnIntersectionExitTrigger: number;
  70525. /**
  70526. * On key down
  70527. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70528. */
  70529. static readonly OnKeyDownTrigger: number;
  70530. /**
  70531. * On key up
  70532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70533. */
  70534. static readonly OnKeyUpTrigger: number;
  70535. private _scene;
  70536. /**
  70537. * Creates a new action manager
  70538. * @param scene defines the hosting scene
  70539. */
  70540. constructor(scene: Scene);
  70541. /**
  70542. * Releases all associated resources
  70543. */
  70544. dispose(): void;
  70545. /**
  70546. * Gets hosting scene
  70547. * @returns the hosting scene
  70548. */
  70549. getScene(): Scene;
  70550. /**
  70551. * Does this action manager handles actions of any of the given triggers
  70552. * @param triggers defines the triggers to be tested
  70553. * @return a boolean indicating whether one (or more) of the triggers is handled
  70554. */
  70555. hasSpecificTriggers(triggers: number[]): boolean;
  70556. /**
  70557. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70558. * speed.
  70559. * @param triggerA defines the trigger to be tested
  70560. * @param triggerB defines the trigger to be tested
  70561. * @return a boolean indicating whether one (or more) of the triggers is handled
  70562. */
  70563. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70564. /**
  70565. * Does this action manager handles actions of a given trigger
  70566. * @param trigger defines the trigger to be tested
  70567. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70568. * @return whether the trigger is handled
  70569. */
  70570. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70571. /**
  70572. * Does this action manager has pointer triggers
  70573. */
  70574. readonly hasPointerTriggers: boolean;
  70575. /**
  70576. * Does this action manager has pick triggers
  70577. */
  70578. readonly hasPickTriggers: boolean;
  70579. /**
  70580. * Registers an action to this action manager
  70581. * @param action defines the action to be registered
  70582. * @return the action amended (prepared) after registration
  70583. */
  70584. registerAction(action: IAction): Nullable<IAction>;
  70585. /**
  70586. * Unregisters an action to this action manager
  70587. * @param action defines the action to be unregistered
  70588. * @return a boolean indicating whether the action has been unregistered
  70589. */
  70590. unregisterAction(action: IAction): Boolean;
  70591. /**
  70592. * Process a specific trigger
  70593. * @param trigger defines the trigger to process
  70594. * @param evt defines the event details to be processed
  70595. */
  70596. processTrigger(trigger: number, evt?: IActionEvent): void;
  70597. /** @hidden */
  70598. _getEffectiveTarget(target: any, propertyPath: string): any;
  70599. /** @hidden */
  70600. _getProperty(propertyPath: string): string;
  70601. /**
  70602. * Serialize this manager to a JSON object
  70603. * @param name defines the property name to store this manager
  70604. * @returns a JSON representation of this manager
  70605. */
  70606. serialize(name: string): any;
  70607. /**
  70608. * Creates a new ActionManager from a JSON data
  70609. * @param parsedActions defines the JSON data to read from
  70610. * @param object defines the hosting mesh
  70611. * @param scene defines the hosting scene
  70612. */
  70613. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70614. /**
  70615. * Get a trigger name by index
  70616. * @param trigger defines the trigger index
  70617. * @returns a trigger name
  70618. */
  70619. static GetTriggerName(trigger: number): string;
  70620. }
  70621. }
  70622. declare module BABYLON {
  70623. /**
  70624. * Class representing a ray with position and direction
  70625. */
  70626. export class Ray {
  70627. /** origin point */
  70628. origin: Vector3;
  70629. /** direction */
  70630. direction: Vector3;
  70631. /** length of the ray */
  70632. length: number;
  70633. private static readonly TmpVector3;
  70634. private _tmpRay;
  70635. /**
  70636. * Creates a new ray
  70637. * @param origin origin point
  70638. * @param direction direction
  70639. * @param length length of the ray
  70640. */
  70641. constructor(
  70642. /** origin point */
  70643. origin: Vector3,
  70644. /** direction */
  70645. direction: Vector3,
  70646. /** length of the ray */
  70647. length?: number);
  70648. /**
  70649. * Checks if the ray intersects a box
  70650. * @param minimum bound of the box
  70651. * @param maximum bound of the box
  70652. * @param intersectionTreshold extra extend to be added to the box in all direction
  70653. * @returns if the box was hit
  70654. */
  70655. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70656. /**
  70657. * Checks if the ray intersects a box
  70658. * @param box the bounding box to check
  70659. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70660. * @returns if the box was hit
  70661. */
  70662. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70663. /**
  70664. * If the ray hits a sphere
  70665. * @param sphere the bounding sphere to check
  70666. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70667. * @returns true if it hits the sphere
  70668. */
  70669. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70670. /**
  70671. * If the ray hits a triange
  70672. * @param vertex0 triangle vertex
  70673. * @param vertex1 triangle vertex
  70674. * @param vertex2 triangle vertex
  70675. * @returns intersection information if hit
  70676. */
  70677. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70678. /**
  70679. * Checks if ray intersects a plane
  70680. * @param plane the plane to check
  70681. * @returns the distance away it was hit
  70682. */
  70683. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70684. /**
  70685. * Checks if ray intersects a mesh
  70686. * @param mesh the mesh to check
  70687. * @param fastCheck if only the bounding box should checked
  70688. * @returns picking info of the intersecton
  70689. */
  70690. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70691. /**
  70692. * Checks if ray intersects a mesh
  70693. * @param meshes the meshes to check
  70694. * @param fastCheck if only the bounding box should checked
  70695. * @param results array to store result in
  70696. * @returns Array of picking infos
  70697. */
  70698. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70699. private _comparePickingInfo;
  70700. private static smallnum;
  70701. private static rayl;
  70702. /**
  70703. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70704. * @param sega the first point of the segment to test the intersection against
  70705. * @param segb the second point of the segment to test the intersection against
  70706. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70707. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70708. */
  70709. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70710. /**
  70711. * Update the ray from viewport position
  70712. * @param x position
  70713. * @param y y position
  70714. * @param viewportWidth viewport width
  70715. * @param viewportHeight viewport height
  70716. * @param world world matrix
  70717. * @param view view matrix
  70718. * @param projection projection matrix
  70719. * @returns this ray updated
  70720. */
  70721. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70722. /**
  70723. * Creates a ray with origin and direction of 0,0,0
  70724. * @returns the new ray
  70725. */
  70726. static Zero(): Ray;
  70727. /**
  70728. * Creates a new ray from screen space and viewport
  70729. * @param x position
  70730. * @param y y position
  70731. * @param viewportWidth viewport width
  70732. * @param viewportHeight viewport height
  70733. * @param world world matrix
  70734. * @param view view matrix
  70735. * @param projection projection matrix
  70736. * @returns new ray
  70737. */
  70738. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70739. /**
  70740. * 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
  70741. * transformed to the given world matrix.
  70742. * @param origin The origin point
  70743. * @param end The end point
  70744. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70745. * @returns the new ray
  70746. */
  70747. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70748. /**
  70749. * Transforms a ray by a matrix
  70750. * @param ray ray to transform
  70751. * @param matrix matrix to apply
  70752. * @returns the resulting new ray
  70753. */
  70754. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70755. /**
  70756. * Transforms a ray by a matrix
  70757. * @param ray ray to transform
  70758. * @param matrix matrix to apply
  70759. * @param result ray to store result in
  70760. */
  70761. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70762. /**
  70763. * Unproject a ray from screen space to object space
  70764. * @param sourceX defines the screen space x coordinate to use
  70765. * @param sourceY defines the screen space y coordinate to use
  70766. * @param viewportWidth defines the current width of the viewport
  70767. * @param viewportHeight defines the current height of the viewport
  70768. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70769. * @param view defines the view matrix to use
  70770. * @param projection defines the projection matrix to use
  70771. */
  70772. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70773. }
  70774. /**
  70775. * Type used to define predicate used to select faces when a mesh intersection is detected
  70776. */
  70777. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70778. interface Scene {
  70779. /** @hidden */
  70780. _tempPickingRay: Nullable<Ray>;
  70781. /** @hidden */
  70782. _cachedRayForTransform: Ray;
  70783. /** @hidden */
  70784. _pickWithRayInverseMatrix: Matrix;
  70785. /** @hidden */
  70786. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70787. /** @hidden */
  70788. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70789. }
  70790. }
  70791. declare module BABYLON {
  70792. /**
  70793. * Groups all the scene component constants in one place to ease maintenance.
  70794. * @hidden
  70795. */
  70796. export class SceneComponentConstants {
  70797. static readonly NAME_EFFECTLAYER: string;
  70798. static readonly NAME_LAYER: string;
  70799. static readonly NAME_LENSFLARESYSTEM: string;
  70800. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70801. static readonly NAME_PARTICLESYSTEM: string;
  70802. static readonly NAME_GAMEPAD: string;
  70803. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70804. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70805. static readonly NAME_DEPTHRENDERER: string;
  70806. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70807. static readonly NAME_SPRITE: string;
  70808. static readonly NAME_OUTLINERENDERER: string;
  70809. static readonly NAME_PROCEDURALTEXTURE: string;
  70810. static readonly NAME_SHADOWGENERATOR: string;
  70811. static readonly NAME_OCTREE: string;
  70812. static readonly NAME_PHYSICSENGINE: string;
  70813. static readonly NAME_AUDIO: string;
  70814. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70815. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70816. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70817. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70818. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70819. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70820. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70821. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70822. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70823. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70824. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70825. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70826. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70827. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70828. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70829. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70830. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70831. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70832. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70833. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70834. static readonly STEP_AFTERRENDER_AUDIO: number;
  70835. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70836. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70837. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70838. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70839. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70840. static readonly STEP_POINTERMOVE_SPRITE: number;
  70841. static readonly STEP_POINTERDOWN_SPRITE: number;
  70842. static readonly STEP_POINTERUP_SPRITE: number;
  70843. }
  70844. /**
  70845. * This represents a scene component.
  70846. *
  70847. * This is used to decouple the dependency the scene is having on the different workloads like
  70848. * layers, post processes...
  70849. */
  70850. export interface ISceneComponent {
  70851. /**
  70852. * The name of the component. Each component must have a unique name.
  70853. */
  70854. name: string;
  70855. /**
  70856. * The scene the component belongs to.
  70857. */
  70858. scene: Scene;
  70859. /**
  70860. * Register the component to one instance of a scene.
  70861. */
  70862. register(): void;
  70863. /**
  70864. * Rebuilds the elements related to this component in case of
  70865. * context lost for instance.
  70866. */
  70867. rebuild(): void;
  70868. /**
  70869. * Disposes the component and the associated ressources.
  70870. */
  70871. dispose(): void;
  70872. }
  70873. /**
  70874. * This represents a SERIALIZABLE scene component.
  70875. *
  70876. * This extends Scene Component to add Serialization methods on top.
  70877. */
  70878. export interface ISceneSerializableComponent extends ISceneComponent {
  70879. /**
  70880. * Adds all the element from the container to the scene
  70881. * @param container the container holding the elements
  70882. */
  70883. addFromContainer(container: AbstractScene): void;
  70884. /**
  70885. * Removes all the elements in the container from the scene
  70886. * @param container contains the elements to remove
  70887. * @param dispose if the removed element should be disposed (default: false)
  70888. */
  70889. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  70890. /**
  70891. * Serializes the component data to the specified json object
  70892. * @param serializationObject The object to serialize to
  70893. */
  70894. serialize(serializationObject: any): void;
  70895. }
  70896. /**
  70897. * Strong typing of a Mesh related stage step action
  70898. */
  70899. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  70900. /**
  70901. * Strong typing of a Evaluate Sub Mesh related stage step action
  70902. */
  70903. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  70904. /**
  70905. * Strong typing of a Active Mesh related stage step action
  70906. */
  70907. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  70908. /**
  70909. * Strong typing of a Camera related stage step action
  70910. */
  70911. export type CameraStageAction = (camera: Camera) => void;
  70912. /**
  70913. * Strong typing of a Camera Frame buffer related stage step action
  70914. */
  70915. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  70916. /**
  70917. * Strong typing of a Render Target related stage step action
  70918. */
  70919. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  70920. /**
  70921. * Strong typing of a RenderingGroup related stage step action
  70922. */
  70923. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  70924. /**
  70925. * Strong typing of a Mesh Render related stage step action
  70926. */
  70927. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  70928. /**
  70929. * Strong typing of a simple stage step action
  70930. */
  70931. export type SimpleStageAction = () => void;
  70932. /**
  70933. * Strong typing of a render target action.
  70934. */
  70935. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  70936. /**
  70937. * Strong typing of a pointer move action.
  70938. */
  70939. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  70940. /**
  70941. * Strong typing of a pointer up/down action.
  70942. */
  70943. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  70944. /**
  70945. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  70946. * @hidden
  70947. */
  70948. export class Stage<T extends Function> extends Array<{
  70949. index: number;
  70950. component: ISceneComponent;
  70951. action: T;
  70952. }> {
  70953. /**
  70954. * Hide ctor from the rest of the world.
  70955. * @param items The items to add.
  70956. */
  70957. private constructor();
  70958. /**
  70959. * Creates a new Stage.
  70960. * @returns A new instance of a Stage
  70961. */
  70962. static Create<T extends Function>(): Stage<T>;
  70963. /**
  70964. * Registers a step in an ordered way in the targeted stage.
  70965. * @param index Defines the position to register the step in
  70966. * @param component Defines the component attached to the step
  70967. * @param action Defines the action to launch during the step
  70968. */
  70969. registerStep(index: number, component: ISceneComponent, action: T): void;
  70970. /**
  70971. * Clears all the steps from the stage.
  70972. */
  70973. clear(): void;
  70974. }
  70975. }
  70976. declare module BABYLON {
  70977. interface Scene {
  70978. /** @hidden */
  70979. _pointerOverSprite: Nullable<Sprite>;
  70980. /** @hidden */
  70981. _pickedDownSprite: Nullable<Sprite>;
  70982. /** @hidden */
  70983. _tempSpritePickingRay: Nullable<Ray>;
  70984. /**
  70985. * All of the sprite managers added to this scene
  70986. * @see http://doc.babylonjs.com/babylon101/sprites
  70987. */
  70988. spriteManagers: Array<ISpriteManager>;
  70989. /**
  70990. * An event triggered when sprites rendering is about to start
  70991. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70992. */
  70993. onBeforeSpritesRenderingObservable: Observable<Scene>;
  70994. /**
  70995. * An event triggered when sprites rendering is done
  70996. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  70997. */
  70998. onAfterSpritesRenderingObservable: Observable<Scene>;
  70999. /** @hidden */
  71000. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71001. /** Launch a ray to try to pick a sprite in the scene
  71002. * @param x position on screen
  71003. * @param y position on screen
  71004. * @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
  71005. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71006. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71007. * @returns a PickingInfo
  71008. */
  71009. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71010. /** Use the given ray to pick a sprite in the scene
  71011. * @param ray The ray (in world space) to use to pick meshes
  71012. * @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
  71013. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71014. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71015. * @returns a PickingInfo
  71016. */
  71017. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71018. /**
  71019. * Force the sprite under the pointer
  71020. * @param sprite defines the sprite to use
  71021. */
  71022. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71023. /**
  71024. * Gets the sprite under the pointer
  71025. * @returns a Sprite or null if no sprite is under the pointer
  71026. */
  71027. getPointerOverSprite(): Nullable<Sprite>;
  71028. }
  71029. /**
  71030. * Defines the sprite scene component responsible to manage sprites
  71031. * in a given scene.
  71032. */
  71033. export class SpriteSceneComponent implements ISceneComponent {
  71034. /**
  71035. * The component name helpfull to identify the component in the list of scene components.
  71036. */
  71037. readonly name: string;
  71038. /**
  71039. * The scene the component belongs to.
  71040. */
  71041. scene: Scene;
  71042. /** @hidden */
  71043. private _spritePredicate;
  71044. /**
  71045. * Creates a new instance of the component for the given scene
  71046. * @param scene Defines the scene to register the component in
  71047. */
  71048. constructor(scene: Scene);
  71049. /**
  71050. * Registers the component in a given scene
  71051. */
  71052. register(): void;
  71053. /**
  71054. * Rebuilds the elements related to this component in case of
  71055. * context lost for instance.
  71056. */
  71057. rebuild(): void;
  71058. /**
  71059. * Disposes the component and the associated ressources.
  71060. */
  71061. dispose(): void;
  71062. private _pickSpriteButKeepRay;
  71063. private _pointerMove;
  71064. private _pointerDown;
  71065. private _pointerUp;
  71066. }
  71067. }
  71068. declare module BABYLON {
  71069. /** @hidden */
  71070. export var fogFragmentDeclaration: {
  71071. name: string;
  71072. shader: string;
  71073. };
  71074. }
  71075. declare module BABYLON {
  71076. /** @hidden */
  71077. export var fogFragment: {
  71078. name: string;
  71079. shader: string;
  71080. };
  71081. }
  71082. declare module BABYLON {
  71083. /** @hidden */
  71084. export var spritesPixelShader: {
  71085. name: string;
  71086. shader: string;
  71087. };
  71088. }
  71089. declare module BABYLON {
  71090. /** @hidden */
  71091. export var fogVertexDeclaration: {
  71092. name: string;
  71093. shader: string;
  71094. };
  71095. }
  71096. declare module BABYLON {
  71097. /** @hidden */
  71098. export var spritesVertexShader: {
  71099. name: string;
  71100. shader: string;
  71101. };
  71102. }
  71103. declare module BABYLON {
  71104. /**
  71105. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71106. */
  71107. export interface ISpriteManager extends IDisposable {
  71108. /**
  71109. * Restricts the camera to viewing objects with the same layerMask.
  71110. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71111. */
  71112. layerMask: number;
  71113. /**
  71114. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71115. */
  71116. isPickable: boolean;
  71117. /**
  71118. * Specifies the rendering group id for this mesh (0 by default)
  71119. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71120. */
  71121. renderingGroupId: number;
  71122. /**
  71123. * Defines the list of sprites managed by the manager.
  71124. */
  71125. sprites: Array<Sprite>;
  71126. /**
  71127. * Tests the intersection of a sprite with a specific ray.
  71128. * @param ray The ray we are sending to test the collision
  71129. * @param camera The camera space we are sending rays in
  71130. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71131. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71132. * @returns picking info or null.
  71133. */
  71134. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71135. /**
  71136. * Renders the list of sprites on screen.
  71137. */
  71138. render(): void;
  71139. }
  71140. /**
  71141. * Class used to manage multiple sprites on the same spritesheet
  71142. * @see http://doc.babylonjs.com/babylon101/sprites
  71143. */
  71144. export class SpriteManager implements ISpriteManager {
  71145. /** defines the manager's name */
  71146. name: string;
  71147. /** Gets the list of sprites */
  71148. sprites: Sprite[];
  71149. /** Gets or sets the rendering group id (0 by default) */
  71150. renderingGroupId: number;
  71151. /** Gets or sets camera layer mask */
  71152. layerMask: number;
  71153. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71154. fogEnabled: boolean;
  71155. /** Gets or sets a boolean indicating if the sprites are pickable */
  71156. isPickable: boolean;
  71157. /** Defines the default width of a cell in the spritesheet */
  71158. cellWidth: number;
  71159. /** Defines the default height of a cell in the spritesheet */
  71160. cellHeight: number;
  71161. /**
  71162. * An event triggered when the manager is disposed.
  71163. */
  71164. onDisposeObservable: Observable<SpriteManager>;
  71165. private _onDisposeObserver;
  71166. /**
  71167. * Callback called when the manager is disposed
  71168. */
  71169. onDispose: () => void;
  71170. private _capacity;
  71171. private _spriteTexture;
  71172. private _epsilon;
  71173. private _scene;
  71174. private _vertexData;
  71175. private _buffer;
  71176. private _vertexBuffers;
  71177. private _indexBuffer;
  71178. private _effectBase;
  71179. private _effectFog;
  71180. /**
  71181. * Gets or sets the spritesheet texture
  71182. */
  71183. texture: Texture;
  71184. /**
  71185. * Creates a new sprite manager
  71186. * @param name defines the manager's name
  71187. * @param imgUrl defines the sprite sheet url
  71188. * @param capacity defines the maximum allowed number of sprites
  71189. * @param cellSize defines the size of a sprite cell
  71190. * @param scene defines the hosting scene
  71191. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71192. * @param samplingMode defines the smapling mode to use with spritesheet
  71193. */
  71194. constructor(
  71195. /** defines the manager's name */
  71196. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71197. private _appendSpriteVertex;
  71198. /**
  71199. * Intersects the sprites with a ray
  71200. * @param ray defines the ray to intersect with
  71201. * @param camera defines the current active camera
  71202. * @param predicate defines a predicate used to select candidate sprites
  71203. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71204. * @returns null if no hit or a PickingInfo
  71205. */
  71206. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71207. /**
  71208. * Render all child sprites
  71209. */
  71210. render(): void;
  71211. /**
  71212. * Release associated resources
  71213. */
  71214. dispose(): void;
  71215. }
  71216. }
  71217. declare module BABYLON {
  71218. /**
  71219. * Class used to represent a sprite
  71220. * @see http://doc.babylonjs.com/babylon101/sprites
  71221. */
  71222. export class Sprite {
  71223. /** defines the name */
  71224. name: string;
  71225. /** Gets or sets the current world position */
  71226. position: Vector3;
  71227. /** Gets or sets the main color */
  71228. color: Color4;
  71229. /** Gets or sets the width */
  71230. width: number;
  71231. /** Gets or sets the height */
  71232. height: number;
  71233. /** Gets or sets rotation angle */
  71234. angle: number;
  71235. /** Gets or sets the cell index in the sprite sheet */
  71236. cellIndex: number;
  71237. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71238. invertU: number;
  71239. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71240. invertV: number;
  71241. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71242. disposeWhenFinishedAnimating: boolean;
  71243. /** Gets the list of attached animations */
  71244. animations: Animation[];
  71245. /** Gets or sets a boolean indicating if the sprite can be picked */
  71246. isPickable: boolean;
  71247. /**
  71248. * Gets or sets the associated action manager
  71249. */
  71250. actionManager: Nullable<ActionManager>;
  71251. private _animationStarted;
  71252. private _loopAnimation;
  71253. private _fromIndex;
  71254. private _toIndex;
  71255. private _delay;
  71256. private _direction;
  71257. private _manager;
  71258. private _time;
  71259. private _onAnimationEnd;
  71260. /**
  71261. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71262. */
  71263. isVisible: boolean;
  71264. /**
  71265. * Gets or sets the sprite size
  71266. */
  71267. size: number;
  71268. /**
  71269. * Creates a new Sprite
  71270. * @param name defines the name
  71271. * @param manager defines the manager
  71272. */
  71273. constructor(
  71274. /** defines the name */
  71275. name: string, manager: ISpriteManager);
  71276. /**
  71277. * Starts an animation
  71278. * @param from defines the initial key
  71279. * @param to defines the end key
  71280. * @param loop defines if the animation must loop
  71281. * @param delay defines the start delay (in ms)
  71282. * @param onAnimationEnd defines a callback to call when animation ends
  71283. */
  71284. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71285. /** Stops current animation (if any) */
  71286. stopAnimation(): void;
  71287. /** @hidden */
  71288. _animate(deltaTime: number): void;
  71289. /** Release associated resources */
  71290. dispose(): void;
  71291. }
  71292. }
  71293. declare module BABYLON {
  71294. /**
  71295. * Information about the result of picking within a scene
  71296. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71297. */
  71298. export class PickingInfo {
  71299. /** @hidden */
  71300. _pickingUnavailable: boolean;
  71301. /**
  71302. * If the pick collided with an object
  71303. */
  71304. hit: boolean;
  71305. /**
  71306. * Distance away where the pick collided
  71307. */
  71308. distance: number;
  71309. /**
  71310. * The location of pick collision
  71311. */
  71312. pickedPoint: Nullable<Vector3>;
  71313. /**
  71314. * The mesh corresponding the the pick collision
  71315. */
  71316. pickedMesh: Nullable<AbstractMesh>;
  71317. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71318. bu: number;
  71319. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71320. bv: number;
  71321. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71322. faceId: number;
  71323. /** Id of the the submesh that was picked */
  71324. subMeshId: number;
  71325. /** If a sprite was picked, this will be the sprite the pick collided with */
  71326. pickedSprite: Nullable<Sprite>;
  71327. /**
  71328. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71329. */
  71330. originMesh: Nullable<AbstractMesh>;
  71331. /**
  71332. * The ray that was used to perform the picking.
  71333. */
  71334. ray: Nullable<Ray>;
  71335. /**
  71336. * Gets the normal correspodning to the face the pick collided with
  71337. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71338. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71339. * @returns The normal correspodning to the face the pick collided with
  71340. */
  71341. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71342. /**
  71343. * Gets the texture coordinates of where the pick occured
  71344. * @returns the vector containing the coordnates of the texture
  71345. */
  71346. getTextureCoordinates(): Nullable<Vector2>;
  71347. }
  71348. }
  71349. declare module BABYLON {
  71350. /**
  71351. * Gather the list of pointer event types as constants.
  71352. */
  71353. export class PointerEventTypes {
  71354. /**
  71355. * 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.
  71356. */
  71357. static readonly POINTERDOWN: number;
  71358. /**
  71359. * The pointerup event is fired when a pointer is no longer active.
  71360. */
  71361. static readonly POINTERUP: number;
  71362. /**
  71363. * The pointermove event is fired when a pointer changes coordinates.
  71364. */
  71365. static readonly POINTERMOVE: number;
  71366. /**
  71367. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71368. */
  71369. static readonly POINTERWHEEL: number;
  71370. /**
  71371. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71372. */
  71373. static readonly POINTERPICK: number;
  71374. /**
  71375. * The pointertap event is fired when a the object has been touched and released without drag.
  71376. */
  71377. static readonly POINTERTAP: number;
  71378. /**
  71379. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71380. */
  71381. static readonly POINTERDOUBLETAP: number;
  71382. }
  71383. /**
  71384. * Base class of pointer info types.
  71385. */
  71386. export class PointerInfoBase {
  71387. /**
  71388. * Defines the type of event (PointerEventTypes)
  71389. */
  71390. type: number;
  71391. /**
  71392. * Defines the related dom event
  71393. */
  71394. event: PointerEvent | MouseWheelEvent;
  71395. /**
  71396. * Instantiates the base class of pointers info.
  71397. * @param type Defines the type of event (PointerEventTypes)
  71398. * @param event Defines the related dom event
  71399. */
  71400. constructor(
  71401. /**
  71402. * Defines the type of event (PointerEventTypes)
  71403. */
  71404. type: number,
  71405. /**
  71406. * Defines the related dom event
  71407. */
  71408. event: PointerEvent | MouseWheelEvent);
  71409. }
  71410. /**
  71411. * This class is used to store pointer related info for the onPrePointerObservable event.
  71412. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71413. */
  71414. export class PointerInfoPre extends PointerInfoBase {
  71415. /**
  71416. * Ray from a pointer if availible (eg. 6dof controller)
  71417. */
  71418. ray: Nullable<Ray>;
  71419. /**
  71420. * Defines the local position of the pointer on the canvas.
  71421. */
  71422. localPosition: Vector2;
  71423. /**
  71424. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71425. */
  71426. skipOnPointerObservable: boolean;
  71427. /**
  71428. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71429. * @param type Defines the type of event (PointerEventTypes)
  71430. * @param event Defines the related dom event
  71431. * @param localX Defines the local x coordinates of the pointer when the event occured
  71432. * @param localY Defines the local y coordinates of the pointer when the event occured
  71433. */
  71434. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71435. }
  71436. /**
  71437. * This type contains all the data related to a pointer event in Babylon.js.
  71438. * 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.
  71439. */
  71440. export class PointerInfo extends PointerInfoBase {
  71441. /**
  71442. * Defines the picking info associated to the info (if any)\
  71443. */
  71444. pickInfo: Nullable<PickingInfo>;
  71445. /**
  71446. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71447. * @param type Defines the type of event (PointerEventTypes)
  71448. * @param event Defines the related dom event
  71449. * @param pickInfo Defines the picking info associated to the info (if any)\
  71450. */
  71451. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71452. /**
  71453. * Defines the picking info associated to the info (if any)\
  71454. */
  71455. pickInfo: Nullable<PickingInfo>);
  71456. }
  71457. /**
  71458. * Data relating to a touch event on the screen.
  71459. */
  71460. export interface PointerTouch {
  71461. /**
  71462. * X coordinate of touch.
  71463. */
  71464. x: number;
  71465. /**
  71466. * Y coordinate of touch.
  71467. */
  71468. y: number;
  71469. /**
  71470. * Id of touch. Unique for each finger.
  71471. */
  71472. pointerId: number;
  71473. /**
  71474. * Event type passed from DOM.
  71475. */
  71476. type: any;
  71477. }
  71478. }
  71479. declare module BABYLON {
  71480. /**
  71481. * Manage the mouse inputs to control the movement of a free camera.
  71482. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71483. */
  71484. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71485. /**
  71486. * Define if touch is enabled in the mouse input
  71487. */
  71488. touchEnabled: boolean;
  71489. /**
  71490. * Defines the camera the input is attached to.
  71491. */
  71492. camera: FreeCamera;
  71493. /**
  71494. * Defines the buttons associated with the input to handle camera move.
  71495. */
  71496. buttons: number[];
  71497. /**
  71498. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71499. */
  71500. angularSensibility: number;
  71501. private _pointerInput;
  71502. private _onMouseMove;
  71503. private _observer;
  71504. private previousPosition;
  71505. /**
  71506. * Observable for when a pointer move event occurs containing the move offset
  71507. */
  71508. onPointerMovedObservable: Observable<{
  71509. offsetX: number;
  71510. offsetY: number;
  71511. }>;
  71512. /**
  71513. * @hidden
  71514. * If the camera should be rotated automatically based on pointer movement
  71515. */
  71516. _allowCameraRotation: boolean;
  71517. /**
  71518. * Manage the mouse inputs to control the movement of a free camera.
  71519. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71520. * @param touchEnabled Defines if touch is enabled or not
  71521. */
  71522. constructor(
  71523. /**
  71524. * Define if touch is enabled in the mouse input
  71525. */
  71526. touchEnabled?: boolean);
  71527. /**
  71528. * Attach the input controls to a specific dom element to get the input from.
  71529. * @param element Defines the element the controls should be listened from
  71530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71531. */
  71532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71533. /**
  71534. * Called on JS contextmenu event.
  71535. * Override this method to provide functionality.
  71536. */
  71537. protected onContextMenu(evt: PointerEvent): void;
  71538. /**
  71539. * Detach the current controls from the specified dom element.
  71540. * @param element Defines the element to stop listening the inputs from
  71541. */
  71542. detachControl(element: Nullable<HTMLElement>): void;
  71543. /**
  71544. * Gets the class name of the current intput.
  71545. * @returns the class name
  71546. */
  71547. getClassName(): string;
  71548. /**
  71549. * Get the friendly name associated with the input class.
  71550. * @returns the input friendly name
  71551. */
  71552. getSimpleName(): string;
  71553. }
  71554. }
  71555. declare module BABYLON {
  71556. /**
  71557. * Manage the touch inputs to control the movement of a free camera.
  71558. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71559. */
  71560. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71561. /**
  71562. * Defines the camera the input is attached to.
  71563. */
  71564. camera: FreeCamera;
  71565. /**
  71566. * Defines the touch sensibility for rotation.
  71567. * The higher the faster.
  71568. */
  71569. touchAngularSensibility: number;
  71570. /**
  71571. * Defines the touch sensibility for move.
  71572. * The higher the faster.
  71573. */
  71574. touchMoveSensibility: number;
  71575. private _offsetX;
  71576. private _offsetY;
  71577. private _pointerPressed;
  71578. private _pointerInput;
  71579. private _observer;
  71580. private _onLostFocus;
  71581. /**
  71582. * Attach the input controls to a specific dom element to get the input from.
  71583. * @param element Defines the element the controls should be listened from
  71584. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71585. */
  71586. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71587. /**
  71588. * Detach the current controls from the specified dom element.
  71589. * @param element Defines the element to stop listening the inputs from
  71590. */
  71591. detachControl(element: Nullable<HTMLElement>): void;
  71592. /**
  71593. * Update the current camera state depending on the inputs that have been used this frame.
  71594. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71595. */
  71596. checkInputs(): void;
  71597. /**
  71598. * Gets the class name of the current intput.
  71599. * @returns the class name
  71600. */
  71601. getClassName(): string;
  71602. /**
  71603. * Get the friendly name associated with the input class.
  71604. * @returns the input friendly name
  71605. */
  71606. getSimpleName(): string;
  71607. }
  71608. }
  71609. declare module BABYLON {
  71610. /**
  71611. * Default Inputs manager for the FreeCamera.
  71612. * It groups all the default supported inputs for ease of use.
  71613. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71614. */
  71615. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71616. /**
  71617. * @hidden
  71618. */
  71619. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71620. /**
  71621. * @hidden
  71622. */
  71623. _mouseInput: Nullable<FreeCameraMouseInput>;
  71624. /**
  71625. * Instantiates a new FreeCameraInputsManager.
  71626. * @param camera Defines the camera the inputs belong to
  71627. */
  71628. constructor(camera: FreeCamera);
  71629. /**
  71630. * Add keyboard input support to the input manager.
  71631. * @returns the current input manager
  71632. */
  71633. addKeyboard(): FreeCameraInputsManager;
  71634. /**
  71635. * Add mouse input support to the input manager.
  71636. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71637. * @returns the current input manager
  71638. */
  71639. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71640. /**
  71641. * Removes the mouse input support from the manager
  71642. * @returns the current input manager
  71643. */
  71644. removeMouse(): FreeCameraInputsManager;
  71645. /**
  71646. * Add touch input support to the input manager.
  71647. * @returns the current input manager
  71648. */
  71649. addTouch(): FreeCameraInputsManager;
  71650. }
  71651. }
  71652. declare module BABYLON {
  71653. /**
  71654. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71655. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71656. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71657. */
  71658. export class FreeCamera extends TargetCamera {
  71659. /**
  71660. * Define the collision ellipsoid of the camera.
  71661. * This is helpful to simulate a camera body like the player body around the camera
  71662. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71663. */
  71664. ellipsoid: Vector3;
  71665. /**
  71666. * Define an offset for the position of the ellipsoid around the camera.
  71667. * This can be helpful to determine the center of the body near the gravity center of the body
  71668. * instead of its head.
  71669. */
  71670. ellipsoidOffset: Vector3;
  71671. /**
  71672. * Enable or disable collisions of the camera with the rest of the scene objects.
  71673. */
  71674. checkCollisions: boolean;
  71675. /**
  71676. * Enable or disable gravity on the camera.
  71677. */
  71678. applyGravity: boolean;
  71679. /**
  71680. * Define the input manager associated to the camera.
  71681. */
  71682. inputs: FreeCameraInputsManager;
  71683. /**
  71684. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71685. * Higher values reduce sensitivity.
  71686. */
  71687. /**
  71688. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71689. * Higher values reduce sensitivity.
  71690. */
  71691. angularSensibility: number;
  71692. /**
  71693. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71694. */
  71695. keysUp: number[];
  71696. /**
  71697. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71698. */
  71699. keysDown: number[];
  71700. /**
  71701. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71702. */
  71703. keysLeft: number[];
  71704. /**
  71705. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71706. */
  71707. keysRight: number[];
  71708. /**
  71709. * Event raised when the camera collide with a mesh in the scene.
  71710. */
  71711. onCollide: (collidedMesh: AbstractMesh) => void;
  71712. private _collider;
  71713. private _needMoveForGravity;
  71714. private _oldPosition;
  71715. private _diffPosition;
  71716. private _newPosition;
  71717. /** @hidden */
  71718. _localDirection: Vector3;
  71719. /** @hidden */
  71720. _transformedDirection: Vector3;
  71721. /**
  71722. * Instantiates a Free Camera.
  71723. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71724. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71725. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71726. * @param name Define the name of the camera in the scene
  71727. * @param position Define the start position of the camera in the scene
  71728. * @param scene Define the scene the camera belongs to
  71729. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71730. */
  71731. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71732. /**
  71733. * Attached controls to the current camera.
  71734. * @param element Defines the element the controls should be listened from
  71735. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71736. */
  71737. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71738. /**
  71739. * Detach the current controls from the camera.
  71740. * The camera will stop reacting to inputs.
  71741. * @param element Defines the element to stop listening the inputs from
  71742. */
  71743. detachControl(element: HTMLElement): void;
  71744. private _collisionMask;
  71745. /**
  71746. * Define a collision mask to limit the list of object the camera can collide with
  71747. */
  71748. collisionMask: number;
  71749. /** @hidden */
  71750. _collideWithWorld(displacement: Vector3): void;
  71751. private _onCollisionPositionChange;
  71752. /** @hidden */
  71753. _checkInputs(): void;
  71754. /** @hidden */
  71755. _decideIfNeedsToMove(): boolean;
  71756. /** @hidden */
  71757. _updatePosition(): void;
  71758. /**
  71759. * Destroy the camera and release the current resources hold by it.
  71760. */
  71761. dispose(): void;
  71762. /**
  71763. * Gets the current object class name.
  71764. * @return the class name
  71765. */
  71766. getClassName(): string;
  71767. }
  71768. }
  71769. declare module BABYLON {
  71770. /**
  71771. * Represents a gamepad control stick position
  71772. */
  71773. export class StickValues {
  71774. /**
  71775. * The x component of the control stick
  71776. */
  71777. x: number;
  71778. /**
  71779. * The y component of the control stick
  71780. */
  71781. y: number;
  71782. /**
  71783. * Initializes the gamepad x and y control stick values
  71784. * @param x The x component of the gamepad control stick value
  71785. * @param y The y component of the gamepad control stick value
  71786. */
  71787. constructor(
  71788. /**
  71789. * The x component of the control stick
  71790. */
  71791. x: number,
  71792. /**
  71793. * The y component of the control stick
  71794. */
  71795. y: number);
  71796. }
  71797. /**
  71798. * An interface which manages callbacks for gamepad button changes
  71799. */
  71800. export interface GamepadButtonChanges {
  71801. /**
  71802. * Called when a gamepad has been changed
  71803. */
  71804. changed: boolean;
  71805. /**
  71806. * Called when a gamepad press event has been triggered
  71807. */
  71808. pressChanged: boolean;
  71809. /**
  71810. * Called when a touch event has been triggered
  71811. */
  71812. touchChanged: boolean;
  71813. /**
  71814. * Called when a value has changed
  71815. */
  71816. valueChanged: boolean;
  71817. }
  71818. /**
  71819. * Represents a gamepad
  71820. */
  71821. export class Gamepad {
  71822. /**
  71823. * The id of the gamepad
  71824. */
  71825. id: string;
  71826. /**
  71827. * The index of the gamepad
  71828. */
  71829. index: number;
  71830. /**
  71831. * The browser gamepad
  71832. */
  71833. browserGamepad: any;
  71834. /**
  71835. * Specifies what type of gamepad this represents
  71836. */
  71837. type: number;
  71838. private _leftStick;
  71839. private _rightStick;
  71840. /** @hidden */
  71841. _isConnected: boolean;
  71842. private _leftStickAxisX;
  71843. private _leftStickAxisY;
  71844. private _rightStickAxisX;
  71845. private _rightStickAxisY;
  71846. /**
  71847. * Triggered when the left control stick has been changed
  71848. */
  71849. private _onleftstickchanged;
  71850. /**
  71851. * Triggered when the right control stick has been changed
  71852. */
  71853. private _onrightstickchanged;
  71854. /**
  71855. * Represents a gamepad controller
  71856. */
  71857. static GAMEPAD: number;
  71858. /**
  71859. * Represents a generic controller
  71860. */
  71861. static GENERIC: number;
  71862. /**
  71863. * Represents an XBox controller
  71864. */
  71865. static XBOX: number;
  71866. /**
  71867. * Represents a pose-enabled controller
  71868. */
  71869. static POSE_ENABLED: number;
  71870. /**
  71871. * Specifies whether the left control stick should be Y-inverted
  71872. */
  71873. protected _invertLeftStickY: boolean;
  71874. /**
  71875. * Specifies if the gamepad has been connected
  71876. */
  71877. readonly isConnected: boolean;
  71878. /**
  71879. * Initializes the gamepad
  71880. * @param id The id of the gamepad
  71881. * @param index The index of the gamepad
  71882. * @param browserGamepad The browser gamepad
  71883. * @param leftStickX The x component of the left joystick
  71884. * @param leftStickY The y component of the left joystick
  71885. * @param rightStickX The x component of the right joystick
  71886. * @param rightStickY The y component of the right joystick
  71887. */
  71888. constructor(
  71889. /**
  71890. * The id of the gamepad
  71891. */
  71892. id: string,
  71893. /**
  71894. * The index of the gamepad
  71895. */
  71896. index: number,
  71897. /**
  71898. * The browser gamepad
  71899. */
  71900. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  71901. /**
  71902. * Callback triggered when the left joystick has changed
  71903. * @param callback
  71904. */
  71905. onleftstickchanged(callback: (values: StickValues) => void): void;
  71906. /**
  71907. * Callback triggered when the right joystick has changed
  71908. * @param callback
  71909. */
  71910. onrightstickchanged(callback: (values: StickValues) => void): void;
  71911. /**
  71912. * Gets the left joystick
  71913. */
  71914. /**
  71915. * Sets the left joystick values
  71916. */
  71917. leftStick: StickValues;
  71918. /**
  71919. * Gets the right joystick
  71920. */
  71921. /**
  71922. * Sets the right joystick value
  71923. */
  71924. rightStick: StickValues;
  71925. /**
  71926. * Updates the gamepad joystick positions
  71927. */
  71928. update(): void;
  71929. /**
  71930. * Disposes the gamepad
  71931. */
  71932. dispose(): void;
  71933. }
  71934. /**
  71935. * Represents a generic gamepad
  71936. */
  71937. export class GenericPad extends Gamepad {
  71938. private _buttons;
  71939. private _onbuttondown;
  71940. private _onbuttonup;
  71941. /**
  71942. * Observable triggered when a button has been pressed
  71943. */
  71944. onButtonDownObservable: Observable<number>;
  71945. /**
  71946. * Observable triggered when a button has been released
  71947. */
  71948. onButtonUpObservable: Observable<number>;
  71949. /**
  71950. * Callback triggered when a button has been pressed
  71951. * @param callback Called when a button has been pressed
  71952. */
  71953. onbuttondown(callback: (buttonPressed: number) => void): void;
  71954. /**
  71955. * Callback triggered when a button has been released
  71956. * @param callback Called when a button has been released
  71957. */
  71958. onbuttonup(callback: (buttonReleased: number) => void): void;
  71959. /**
  71960. * Initializes the generic gamepad
  71961. * @param id The id of the generic gamepad
  71962. * @param index The index of the generic gamepad
  71963. * @param browserGamepad The browser gamepad
  71964. */
  71965. constructor(id: string, index: number, browserGamepad: any);
  71966. private _setButtonValue;
  71967. /**
  71968. * Updates the generic gamepad
  71969. */
  71970. update(): void;
  71971. /**
  71972. * Disposes the generic gamepad
  71973. */
  71974. dispose(): void;
  71975. }
  71976. }
  71977. declare module BABYLON {
  71978. /**
  71979. * Defines the types of pose enabled controllers that are supported
  71980. */
  71981. export enum PoseEnabledControllerType {
  71982. /**
  71983. * HTC Vive
  71984. */
  71985. VIVE = 0,
  71986. /**
  71987. * Oculus Rift
  71988. */
  71989. OCULUS = 1,
  71990. /**
  71991. * Windows mixed reality
  71992. */
  71993. WINDOWS = 2,
  71994. /**
  71995. * Samsung gear VR
  71996. */
  71997. GEAR_VR = 3,
  71998. /**
  71999. * Google Daydream
  72000. */
  72001. DAYDREAM = 4,
  72002. /**
  72003. * Generic
  72004. */
  72005. GENERIC = 5
  72006. }
  72007. /**
  72008. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72009. */
  72010. export interface MutableGamepadButton {
  72011. /**
  72012. * Value of the button/trigger
  72013. */
  72014. value: number;
  72015. /**
  72016. * If the button/trigger is currently touched
  72017. */
  72018. touched: boolean;
  72019. /**
  72020. * If the button/trigger is currently pressed
  72021. */
  72022. pressed: boolean;
  72023. }
  72024. /**
  72025. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72026. * @hidden
  72027. */
  72028. export interface ExtendedGamepadButton extends GamepadButton {
  72029. /**
  72030. * If the button/trigger is currently pressed
  72031. */
  72032. readonly pressed: boolean;
  72033. /**
  72034. * If the button/trigger is currently touched
  72035. */
  72036. readonly touched: boolean;
  72037. /**
  72038. * Value of the button/trigger
  72039. */
  72040. readonly value: number;
  72041. }
  72042. /** @hidden */
  72043. export interface _GamePadFactory {
  72044. /**
  72045. * Returns wether or not the current gamepad can be created for this type of controller.
  72046. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72047. * @returns true if it can be created, otherwise false
  72048. */
  72049. canCreate(gamepadInfo: any): boolean;
  72050. /**
  72051. * Creates a new instance of the Gamepad.
  72052. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72053. * @returns the new gamepad instance
  72054. */
  72055. create(gamepadInfo: any): Gamepad;
  72056. }
  72057. /**
  72058. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72059. */
  72060. export class PoseEnabledControllerHelper {
  72061. /** @hidden */
  72062. static _ControllerFactories: _GamePadFactory[];
  72063. /** @hidden */
  72064. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72065. /**
  72066. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72067. * @param vrGamepad the gamepad to initialized
  72068. * @returns a vr controller of the type the gamepad identified as
  72069. */
  72070. static InitiateController(vrGamepad: any): Gamepad;
  72071. }
  72072. /**
  72073. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72074. */
  72075. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72076. private _deviceRoomPosition;
  72077. private _deviceRoomRotationQuaternion;
  72078. /**
  72079. * The device position in babylon space
  72080. */
  72081. devicePosition: Vector3;
  72082. /**
  72083. * The device rotation in babylon space
  72084. */
  72085. deviceRotationQuaternion: Quaternion;
  72086. /**
  72087. * The scale factor of the device in babylon space
  72088. */
  72089. deviceScaleFactor: number;
  72090. /**
  72091. * (Likely devicePosition should be used instead) The device position in its room space
  72092. */
  72093. position: Vector3;
  72094. /**
  72095. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72096. */
  72097. rotationQuaternion: Quaternion;
  72098. /**
  72099. * The type of controller (Eg. Windows mixed reality)
  72100. */
  72101. controllerType: PoseEnabledControllerType;
  72102. protected _calculatedPosition: Vector3;
  72103. private _calculatedRotation;
  72104. /**
  72105. * The raw pose from the device
  72106. */
  72107. rawPose: DevicePose;
  72108. private _trackPosition;
  72109. private _maxRotationDistFromHeadset;
  72110. private _draggedRoomRotation;
  72111. /**
  72112. * @hidden
  72113. */
  72114. _disableTrackPosition(fixedPosition: Vector3): void;
  72115. /**
  72116. * Internal, the mesh attached to the controller
  72117. * @hidden
  72118. */
  72119. _mesh: Nullable<AbstractMesh>;
  72120. private _poseControlledCamera;
  72121. private _leftHandSystemQuaternion;
  72122. /**
  72123. * Internal, matrix used to convert room space to babylon space
  72124. * @hidden
  72125. */
  72126. _deviceToWorld: Matrix;
  72127. /**
  72128. * Node to be used when casting a ray from the controller
  72129. * @hidden
  72130. */
  72131. _pointingPoseNode: Nullable<TransformNode>;
  72132. /**
  72133. * Name of the child mesh that can be used to cast a ray from the controller
  72134. */
  72135. static readonly POINTING_POSE: string;
  72136. /**
  72137. * Creates a new PoseEnabledController from a gamepad
  72138. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72139. */
  72140. constructor(browserGamepad: any);
  72141. private _workingMatrix;
  72142. /**
  72143. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72144. */
  72145. update(): void;
  72146. /**
  72147. * Updates only the pose device and mesh without doing any button event checking
  72148. */
  72149. protected _updatePoseAndMesh(): void;
  72150. /**
  72151. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72152. * @param poseData raw pose fromthe device
  72153. */
  72154. updateFromDevice(poseData: DevicePose): void;
  72155. /**
  72156. * @hidden
  72157. */
  72158. _meshAttachedObservable: Observable<AbstractMesh>;
  72159. /**
  72160. * Attaches a mesh to the controller
  72161. * @param mesh the mesh to be attached
  72162. */
  72163. attachToMesh(mesh: AbstractMesh): void;
  72164. /**
  72165. * Attaches the controllers mesh to a camera
  72166. * @param camera the camera the mesh should be attached to
  72167. */
  72168. attachToPoseControlledCamera(camera: TargetCamera): void;
  72169. /**
  72170. * Disposes of the controller
  72171. */
  72172. dispose(): void;
  72173. /**
  72174. * The mesh that is attached to the controller
  72175. */
  72176. readonly mesh: Nullable<AbstractMesh>;
  72177. /**
  72178. * Gets the ray of the controller in the direction the controller is pointing
  72179. * @param length the length the resulting ray should be
  72180. * @returns a ray in the direction the controller is pointing
  72181. */
  72182. getForwardRay(length?: number): Ray;
  72183. }
  72184. }
  72185. declare module BABYLON {
  72186. /**
  72187. * Defines the WebVRController object that represents controllers tracked in 3D space
  72188. */
  72189. export abstract class WebVRController extends PoseEnabledController {
  72190. /**
  72191. * Internal, the default controller model for the controller
  72192. */
  72193. protected _defaultModel: AbstractMesh;
  72194. /**
  72195. * Fired when the trigger state has changed
  72196. */
  72197. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72198. /**
  72199. * Fired when the main button state has changed
  72200. */
  72201. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72202. /**
  72203. * Fired when the secondary button state has changed
  72204. */
  72205. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72206. /**
  72207. * Fired when the pad state has changed
  72208. */
  72209. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72210. /**
  72211. * Fired when controllers stick values have changed
  72212. */
  72213. onPadValuesChangedObservable: Observable<StickValues>;
  72214. /**
  72215. * Array of button availible on the controller
  72216. */
  72217. protected _buttons: Array<MutableGamepadButton>;
  72218. private _onButtonStateChange;
  72219. /**
  72220. * Fired when a controller button's state has changed
  72221. * @param callback the callback containing the button that was modified
  72222. */
  72223. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72224. /**
  72225. * X and Y axis corrisponding to the controllers joystick
  72226. */
  72227. pad: StickValues;
  72228. /**
  72229. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72230. */
  72231. hand: string;
  72232. /**
  72233. * The default controller model for the controller
  72234. */
  72235. readonly defaultModel: AbstractMesh;
  72236. /**
  72237. * Creates a new WebVRController from a gamepad
  72238. * @param vrGamepad the gamepad that the WebVRController should be created from
  72239. */
  72240. constructor(vrGamepad: any);
  72241. /**
  72242. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72243. */
  72244. update(): void;
  72245. /**
  72246. * Function to be called when a button is modified
  72247. */
  72248. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72249. /**
  72250. * Loads a mesh and attaches it to the controller
  72251. * @param scene the scene the mesh should be added to
  72252. * @param meshLoaded callback for when the mesh has been loaded
  72253. */
  72254. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72255. private _setButtonValue;
  72256. private _changes;
  72257. private _checkChanges;
  72258. /**
  72259. * Disposes of th webVRCOntroller
  72260. */
  72261. dispose(): void;
  72262. }
  72263. }
  72264. declare module BABYLON {
  72265. /**
  72266. * The HemisphericLight simulates the ambient environment light,
  72267. * so the passed direction is the light reflection direction, not the incoming direction.
  72268. */
  72269. export class HemisphericLight extends Light {
  72270. /**
  72271. * The groundColor is the light in the opposite direction to the one specified during creation.
  72272. * 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.
  72273. */
  72274. groundColor: Color3;
  72275. /**
  72276. * The light reflection direction, not the incoming direction.
  72277. */
  72278. direction: Vector3;
  72279. /**
  72280. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72281. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72282. * The HemisphericLight can't cast shadows.
  72283. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72284. * @param name The friendly name of the light
  72285. * @param direction The direction of the light reflection
  72286. * @param scene The scene the light belongs to
  72287. */
  72288. constructor(name: string, direction: Vector3, scene: Scene);
  72289. protected _buildUniformLayout(): void;
  72290. /**
  72291. * Returns the string "HemisphericLight".
  72292. * @return The class name
  72293. */
  72294. getClassName(): string;
  72295. /**
  72296. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72297. * Returns the updated direction.
  72298. * @param target The target the direction should point to
  72299. * @return The computed direction
  72300. */
  72301. setDirectionToTarget(target: Vector3): Vector3;
  72302. /**
  72303. * Returns the shadow generator associated to the light.
  72304. * @returns Always null for hemispheric lights because it does not support shadows.
  72305. */
  72306. getShadowGenerator(): Nullable<IShadowGenerator>;
  72307. /**
  72308. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72309. * @param effect The effect to update
  72310. * @param lightIndex The index of the light in the effect to update
  72311. * @returns The hemispheric light
  72312. */
  72313. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72314. /**
  72315. * Computes the world matrix of the node
  72316. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72317. * @param useWasUpdatedFlag defines a reserved property
  72318. * @returns the world matrix
  72319. */
  72320. computeWorldMatrix(): Matrix;
  72321. /**
  72322. * Returns the integer 3.
  72323. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72324. */
  72325. getTypeID(): number;
  72326. /**
  72327. * Prepares the list of defines specific to the light type.
  72328. * @param defines the list of defines
  72329. * @param lightIndex defines the index of the light for the effect
  72330. */
  72331. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72332. }
  72333. }
  72334. declare module BABYLON {
  72335. /** @hidden */
  72336. export var vrMultiviewToSingleviewPixelShader: {
  72337. name: string;
  72338. shader: string;
  72339. };
  72340. }
  72341. declare module BABYLON {
  72342. /**
  72343. * Renders to multiple views with a single draw call
  72344. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72345. */
  72346. export class MultiviewRenderTarget extends RenderTargetTexture {
  72347. /**
  72348. * Creates a multiview render target
  72349. * @param scene scene used with the render target
  72350. * @param size the size of the render target (used for each view)
  72351. */
  72352. constructor(scene: Scene, size?: number | {
  72353. width: number;
  72354. height: number;
  72355. } | {
  72356. ratio: number;
  72357. });
  72358. /**
  72359. * @hidden
  72360. * @param faceIndex the face index, if its a cube texture
  72361. */
  72362. _bindFrameBuffer(faceIndex?: number): void;
  72363. /**
  72364. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72365. * @returns the view count
  72366. */
  72367. getViewCount(): number;
  72368. }
  72369. }
  72370. declare module BABYLON {
  72371. interface Engine {
  72372. /**
  72373. * Creates a new multiview render target
  72374. * @param width defines the width of the texture
  72375. * @param height defines the height of the texture
  72376. * @returns the created multiview texture
  72377. */
  72378. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72379. /**
  72380. * Binds a multiview framebuffer to be drawn to
  72381. * @param multiviewTexture texture to bind
  72382. */
  72383. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72384. }
  72385. interface Camera {
  72386. /**
  72387. * @hidden
  72388. * 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)
  72389. */
  72390. _useMultiviewToSingleView: boolean;
  72391. /**
  72392. * @hidden
  72393. * 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)
  72394. */
  72395. _multiviewTexture: Nullable<RenderTargetTexture>;
  72396. /**
  72397. * @hidden
  72398. * ensures the multiview texture of the camera exists and has the specified width/height
  72399. * @param width height to set on the multiview texture
  72400. * @param height width to set on the multiview texture
  72401. */
  72402. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72403. }
  72404. interface Scene {
  72405. /** @hidden */
  72406. _transformMatrixR: Matrix;
  72407. /** @hidden */
  72408. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72409. /** @hidden */
  72410. _createMultiviewUbo(): void;
  72411. /** @hidden */
  72412. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72413. /** @hidden */
  72414. _renderMultiviewToSingleView(camera: Camera): void;
  72415. }
  72416. }
  72417. declare module BABYLON {
  72418. /**
  72419. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72420. * This will not be used for webXR as it supports displaying texture arrays directly
  72421. */
  72422. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72423. /**
  72424. * Initializes a VRMultiviewToSingleview
  72425. * @param name name of the post process
  72426. * @param camera camera to be applied to
  72427. * @param scaleFactor scaling factor to the size of the output texture
  72428. */
  72429. constructor(name: string, camera: Camera, scaleFactor: number);
  72430. }
  72431. }
  72432. declare module BABYLON {
  72433. /**
  72434. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72435. * IMPORTANT!! The data is right-hand data.
  72436. * @export
  72437. * @interface DevicePose
  72438. */
  72439. export interface DevicePose {
  72440. /**
  72441. * The position of the device, values in array are [x,y,z].
  72442. */
  72443. readonly position: Nullable<Float32Array>;
  72444. /**
  72445. * The linearVelocity of the device, values in array are [x,y,z].
  72446. */
  72447. readonly linearVelocity: Nullable<Float32Array>;
  72448. /**
  72449. * The linearAcceleration of the device, values in array are [x,y,z].
  72450. */
  72451. readonly linearAcceleration: Nullable<Float32Array>;
  72452. /**
  72453. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72454. */
  72455. readonly orientation: Nullable<Float32Array>;
  72456. /**
  72457. * The angularVelocity of the device, values in array are [x,y,z].
  72458. */
  72459. readonly angularVelocity: Nullable<Float32Array>;
  72460. /**
  72461. * The angularAcceleration of the device, values in array are [x,y,z].
  72462. */
  72463. readonly angularAcceleration: Nullable<Float32Array>;
  72464. }
  72465. /**
  72466. * Interface representing a pose controlled object in Babylon.
  72467. * A pose controlled object has both regular pose values as well as pose values
  72468. * from an external device such as a VR head mounted display
  72469. */
  72470. export interface PoseControlled {
  72471. /**
  72472. * The position of the object in babylon space.
  72473. */
  72474. position: Vector3;
  72475. /**
  72476. * The rotation quaternion of the object in babylon space.
  72477. */
  72478. rotationQuaternion: Quaternion;
  72479. /**
  72480. * The position of the device in babylon space.
  72481. */
  72482. devicePosition?: Vector3;
  72483. /**
  72484. * The rotation quaternion of the device in babylon space.
  72485. */
  72486. deviceRotationQuaternion: Quaternion;
  72487. /**
  72488. * The raw pose coming from the device.
  72489. */
  72490. rawPose: Nullable<DevicePose>;
  72491. /**
  72492. * The scale of the device to be used when translating from device space to babylon space.
  72493. */
  72494. deviceScaleFactor: number;
  72495. /**
  72496. * Updates the poseControlled values based on the input device pose.
  72497. * @param poseData the pose data to update the object with
  72498. */
  72499. updateFromDevice(poseData: DevicePose): void;
  72500. }
  72501. /**
  72502. * Set of options to customize the webVRCamera
  72503. */
  72504. export interface WebVROptions {
  72505. /**
  72506. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72507. */
  72508. trackPosition?: boolean;
  72509. /**
  72510. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72511. */
  72512. positionScale?: number;
  72513. /**
  72514. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72515. */
  72516. displayName?: string;
  72517. /**
  72518. * Should the native controller meshes be initialized. (default: true)
  72519. */
  72520. controllerMeshes?: boolean;
  72521. /**
  72522. * Creating a default HemiLight only on controllers. (default: true)
  72523. */
  72524. defaultLightingOnControllers?: boolean;
  72525. /**
  72526. * If you don't want to use the default VR button of the helper. (default: false)
  72527. */
  72528. useCustomVRButton?: boolean;
  72529. /**
  72530. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72531. */
  72532. customVRButton?: HTMLButtonElement;
  72533. /**
  72534. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72535. */
  72536. rayLength?: number;
  72537. /**
  72538. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72539. */
  72540. defaultHeight?: number;
  72541. /**
  72542. * If multiview should be used if availible (default: false)
  72543. */
  72544. useMultiview?: boolean;
  72545. }
  72546. /**
  72547. * This represents a WebVR camera.
  72548. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72549. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72550. */
  72551. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72552. private webVROptions;
  72553. /**
  72554. * @hidden
  72555. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72556. */
  72557. _vrDevice: any;
  72558. /**
  72559. * The rawPose of the vrDevice.
  72560. */
  72561. rawPose: Nullable<DevicePose>;
  72562. private _onVREnabled;
  72563. private _specsVersion;
  72564. private _attached;
  72565. private _frameData;
  72566. protected _descendants: Array<Node>;
  72567. private _deviceRoomPosition;
  72568. /** @hidden */
  72569. _deviceRoomRotationQuaternion: Quaternion;
  72570. private _standingMatrix;
  72571. /**
  72572. * Represents device position in babylon space.
  72573. */
  72574. devicePosition: Vector3;
  72575. /**
  72576. * Represents device rotation in babylon space.
  72577. */
  72578. deviceRotationQuaternion: Quaternion;
  72579. /**
  72580. * The scale of the device to be used when translating from device space to babylon space.
  72581. */
  72582. deviceScaleFactor: number;
  72583. private _deviceToWorld;
  72584. private _worldToDevice;
  72585. /**
  72586. * References to the webVR controllers for the vrDevice.
  72587. */
  72588. controllers: Array<WebVRController>;
  72589. /**
  72590. * Emits an event when a controller is attached.
  72591. */
  72592. onControllersAttachedObservable: Observable<WebVRController[]>;
  72593. /**
  72594. * Emits an event when a controller's mesh has been loaded;
  72595. */
  72596. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72597. /**
  72598. * Emits an event when the HMD's pose has been updated.
  72599. */
  72600. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72601. private _poseSet;
  72602. /**
  72603. * If the rig cameras be used as parent instead of this camera.
  72604. */
  72605. rigParenting: boolean;
  72606. private _lightOnControllers;
  72607. private _defaultHeight?;
  72608. /**
  72609. * Instantiates a WebVRFreeCamera.
  72610. * @param name The name of the WebVRFreeCamera
  72611. * @param position The starting anchor position for the camera
  72612. * @param scene The scene the camera belongs to
  72613. * @param webVROptions a set of customizable options for the webVRCamera
  72614. */
  72615. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72616. /**
  72617. * Gets the device distance from the ground in meters.
  72618. * @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.
  72619. */
  72620. deviceDistanceToRoomGround(): number;
  72621. /**
  72622. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72623. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72624. */
  72625. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72626. /**
  72627. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72628. * @returns A promise with a boolean set to if the standing matrix is supported.
  72629. */
  72630. useStandingMatrixAsync(): Promise<boolean>;
  72631. /**
  72632. * Disposes the camera
  72633. */
  72634. dispose(): void;
  72635. /**
  72636. * Gets a vrController by name.
  72637. * @param name The name of the controller to retreive
  72638. * @returns the controller matching the name specified or null if not found
  72639. */
  72640. getControllerByName(name: string): Nullable<WebVRController>;
  72641. private _leftController;
  72642. /**
  72643. * The controller corrisponding to the users left hand.
  72644. */
  72645. readonly leftController: Nullable<WebVRController>;
  72646. private _rightController;
  72647. /**
  72648. * The controller corrisponding to the users right hand.
  72649. */
  72650. readonly rightController: Nullable<WebVRController>;
  72651. /**
  72652. * Casts a ray forward from the vrCamera's gaze.
  72653. * @param length Length of the ray (default: 100)
  72654. * @returns the ray corrisponding to the gaze
  72655. */
  72656. getForwardRay(length?: number): Ray;
  72657. /**
  72658. * @hidden
  72659. * Updates the camera based on device's frame data
  72660. */
  72661. _checkInputs(): void;
  72662. /**
  72663. * Updates the poseControlled values based on the input device pose.
  72664. * @param poseData Pose coming from the device
  72665. */
  72666. updateFromDevice(poseData: DevicePose): void;
  72667. private _htmlElementAttached;
  72668. private _detachIfAttached;
  72669. /**
  72670. * WebVR's attach control will start broadcasting frames to the device.
  72671. * Note that in certain browsers (chrome for example) this function must be called
  72672. * within a user-interaction callback. Example:
  72673. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72674. *
  72675. * @param element html element to attach the vrDevice to
  72676. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72677. */
  72678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72679. /**
  72680. * Detaches the camera from the html element and disables VR
  72681. *
  72682. * @param element html element to detach from
  72683. */
  72684. detachControl(element: HTMLElement): void;
  72685. /**
  72686. * @returns the name of this class
  72687. */
  72688. getClassName(): string;
  72689. /**
  72690. * Calls resetPose on the vrDisplay
  72691. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72692. */
  72693. resetToCurrentRotation(): void;
  72694. /**
  72695. * @hidden
  72696. * Updates the rig cameras (left and right eye)
  72697. */
  72698. _updateRigCameras(): void;
  72699. private _workingVector;
  72700. private _oneVector;
  72701. private _workingMatrix;
  72702. private updateCacheCalled;
  72703. private _correctPositionIfNotTrackPosition;
  72704. /**
  72705. * @hidden
  72706. * Updates the cached values of the camera
  72707. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72708. */
  72709. _updateCache(ignoreParentClass?: boolean): void;
  72710. /**
  72711. * @hidden
  72712. * Get current device position in babylon world
  72713. */
  72714. _computeDevicePosition(): void;
  72715. /**
  72716. * Updates the current device position and rotation in the babylon world
  72717. */
  72718. update(): void;
  72719. /**
  72720. * @hidden
  72721. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72722. * @returns an identity matrix
  72723. */
  72724. _getViewMatrix(): Matrix;
  72725. private _tmpMatrix;
  72726. /**
  72727. * This function is called by the two RIG cameras.
  72728. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72729. * @hidden
  72730. */
  72731. _getWebVRViewMatrix(): Matrix;
  72732. /** @hidden */
  72733. _getWebVRProjectionMatrix(): Matrix;
  72734. private _onGamepadConnectedObserver;
  72735. private _onGamepadDisconnectedObserver;
  72736. private _updateCacheWhenTrackingDisabledObserver;
  72737. /**
  72738. * Initializes the controllers and their meshes
  72739. */
  72740. initControllers(): void;
  72741. }
  72742. }
  72743. declare module BABYLON {
  72744. /**
  72745. * Size options for a post process
  72746. */
  72747. export type PostProcessOptions = {
  72748. width: number;
  72749. height: number;
  72750. };
  72751. /**
  72752. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72753. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72754. */
  72755. export class PostProcess {
  72756. /** Name of the PostProcess. */
  72757. name: string;
  72758. /**
  72759. * Gets or sets the unique id of the post process
  72760. */
  72761. uniqueId: number;
  72762. /**
  72763. * Width of the texture to apply the post process on
  72764. */
  72765. width: number;
  72766. /**
  72767. * Height of the texture to apply the post process on
  72768. */
  72769. height: number;
  72770. /**
  72771. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72772. * @hidden
  72773. */
  72774. _outputTexture: Nullable<InternalTexture>;
  72775. /**
  72776. * Sampling mode used by the shader
  72777. * See https://doc.babylonjs.com/classes/3.1/texture
  72778. */
  72779. renderTargetSamplingMode: number;
  72780. /**
  72781. * Clear color to use when screen clearing
  72782. */
  72783. clearColor: Color4;
  72784. /**
  72785. * If the buffer needs to be cleared before applying the post process. (default: true)
  72786. * Should be set to false if shader will overwrite all previous pixels.
  72787. */
  72788. autoClear: boolean;
  72789. /**
  72790. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72791. */
  72792. alphaMode: number;
  72793. /**
  72794. * Sets the setAlphaBlendConstants of the babylon engine
  72795. */
  72796. alphaConstants: Color4;
  72797. /**
  72798. * Animations to be used for the post processing
  72799. */
  72800. animations: Animation[];
  72801. /**
  72802. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72803. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72804. */
  72805. enablePixelPerfectMode: boolean;
  72806. /**
  72807. * Force the postprocess to be applied without taking in account viewport
  72808. */
  72809. forceFullscreenViewport: boolean;
  72810. /**
  72811. * List of inspectable custom properties (used by the Inspector)
  72812. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72813. */
  72814. inspectableCustomProperties: IInspectable[];
  72815. /**
  72816. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72817. *
  72818. * | Value | Type | Description |
  72819. * | ----- | ----------------------------------- | ----------- |
  72820. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72821. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72822. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72823. *
  72824. */
  72825. scaleMode: number;
  72826. /**
  72827. * Force textures to be a power of two (default: false)
  72828. */
  72829. alwaysForcePOT: boolean;
  72830. private _samples;
  72831. /**
  72832. * Number of sample textures (default: 1)
  72833. */
  72834. samples: number;
  72835. /**
  72836. * Modify the scale of the post process to be the same as the viewport (default: false)
  72837. */
  72838. adaptScaleToCurrentViewport: boolean;
  72839. private _camera;
  72840. private _scene;
  72841. private _engine;
  72842. private _options;
  72843. private _reusable;
  72844. private _textureType;
  72845. /**
  72846. * Smart array of input and output textures for the post process.
  72847. * @hidden
  72848. */
  72849. _textures: SmartArray<InternalTexture>;
  72850. /**
  72851. * The index in _textures that corresponds to the output texture.
  72852. * @hidden
  72853. */
  72854. _currentRenderTextureInd: number;
  72855. private _effect;
  72856. private _samplers;
  72857. private _fragmentUrl;
  72858. private _vertexUrl;
  72859. private _parameters;
  72860. private _scaleRatio;
  72861. protected _indexParameters: any;
  72862. private _shareOutputWithPostProcess;
  72863. private _texelSize;
  72864. private _forcedOutputTexture;
  72865. /**
  72866. * Returns the fragment url or shader name used in the post process.
  72867. * @returns the fragment url or name in the shader store.
  72868. */
  72869. getEffectName(): string;
  72870. /**
  72871. * An event triggered when the postprocess is activated.
  72872. */
  72873. onActivateObservable: Observable<Camera>;
  72874. private _onActivateObserver;
  72875. /**
  72876. * A function that is added to the onActivateObservable
  72877. */
  72878. onActivate: Nullable<(camera: Camera) => void>;
  72879. /**
  72880. * An event triggered when the postprocess changes its size.
  72881. */
  72882. onSizeChangedObservable: Observable<PostProcess>;
  72883. private _onSizeChangedObserver;
  72884. /**
  72885. * A function that is added to the onSizeChangedObservable
  72886. */
  72887. onSizeChanged: (postProcess: PostProcess) => void;
  72888. /**
  72889. * An event triggered when the postprocess applies its effect.
  72890. */
  72891. onApplyObservable: Observable<Effect>;
  72892. private _onApplyObserver;
  72893. /**
  72894. * A function that is added to the onApplyObservable
  72895. */
  72896. onApply: (effect: Effect) => void;
  72897. /**
  72898. * An event triggered before rendering the postprocess
  72899. */
  72900. onBeforeRenderObservable: Observable<Effect>;
  72901. private _onBeforeRenderObserver;
  72902. /**
  72903. * A function that is added to the onBeforeRenderObservable
  72904. */
  72905. onBeforeRender: (effect: Effect) => void;
  72906. /**
  72907. * An event triggered after rendering the postprocess
  72908. */
  72909. onAfterRenderObservable: Observable<Effect>;
  72910. private _onAfterRenderObserver;
  72911. /**
  72912. * A function that is added to the onAfterRenderObservable
  72913. */
  72914. onAfterRender: (efect: Effect) => void;
  72915. /**
  72916. * 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
  72917. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  72918. */
  72919. inputTexture: InternalTexture;
  72920. /**
  72921. * Gets the camera which post process is applied to.
  72922. * @returns The camera the post process is applied to.
  72923. */
  72924. getCamera(): Camera;
  72925. /**
  72926. * Gets the texel size of the postprocess.
  72927. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  72928. */
  72929. readonly texelSize: Vector2;
  72930. /**
  72931. * Creates a new instance PostProcess
  72932. * @param name The name of the PostProcess.
  72933. * @param fragmentUrl The url of the fragment shader to be used.
  72934. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  72935. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  72936. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  72937. * @param camera The camera to apply the render pass to.
  72938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72939. * @param engine The engine which the post process will be applied. (default: current engine)
  72940. * @param reusable If the post process can be reused on the same frame. (default: false)
  72941. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  72942. * @param textureType Type of textures used when performing the post process. (default: 0)
  72943. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  72944. * @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
  72945. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  72946. */
  72947. constructor(
  72948. /** Name of the PostProcess. */
  72949. 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);
  72950. /**
  72951. * Gets a string idenfifying the name of the class
  72952. * @returns "PostProcess" string
  72953. */
  72954. getClassName(): string;
  72955. /**
  72956. * Gets the engine which this post process belongs to.
  72957. * @returns The engine the post process was enabled with.
  72958. */
  72959. getEngine(): Engine;
  72960. /**
  72961. * The effect that is created when initializing the post process.
  72962. * @returns The created effect corrisponding the the postprocess.
  72963. */
  72964. getEffect(): Effect;
  72965. /**
  72966. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  72967. * @param postProcess The post process to share the output with.
  72968. * @returns This post process.
  72969. */
  72970. shareOutputWith(postProcess: PostProcess): PostProcess;
  72971. /**
  72972. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  72973. * This should be called if the post process that shares output with this post process is disabled/disposed.
  72974. */
  72975. useOwnOutput(): void;
  72976. /**
  72977. * Updates the effect with the current post process compile time values and recompiles the shader.
  72978. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72979. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72980. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72981. * @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
  72982. * @param onCompiled Called when the shader has been compiled.
  72983. * @param onError Called if there is an error when compiling a shader.
  72984. */
  72985. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72986. /**
  72987. * The post process is reusable if it can be used multiple times within one frame.
  72988. * @returns If the post process is reusable
  72989. */
  72990. isReusable(): boolean;
  72991. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  72992. markTextureDirty(): void;
  72993. /**
  72994. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  72995. * 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.
  72996. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  72997. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  72998. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  72999. * @returns The target texture that was bound to be written to.
  73000. */
  73001. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73002. /**
  73003. * If the post process is supported.
  73004. */
  73005. readonly isSupported: boolean;
  73006. /**
  73007. * The aspect ratio of the output texture.
  73008. */
  73009. readonly aspectRatio: number;
  73010. /**
  73011. * Get a value indicating if the post-process is ready to be used
  73012. * @returns true if the post-process is ready (shader is compiled)
  73013. */
  73014. isReady(): boolean;
  73015. /**
  73016. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73017. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73018. */
  73019. apply(): Nullable<Effect>;
  73020. private _disposeTextures;
  73021. /**
  73022. * Disposes the post process.
  73023. * @param camera The camera to dispose the post process on.
  73024. */
  73025. dispose(camera?: Camera): void;
  73026. }
  73027. }
  73028. declare module BABYLON {
  73029. /**
  73030. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73031. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73032. */
  73033. export class PostProcessManager {
  73034. private _scene;
  73035. private _indexBuffer;
  73036. private _vertexBuffers;
  73037. /**
  73038. * Creates a new instance PostProcess
  73039. * @param scene The scene that the post process is associated with.
  73040. */
  73041. constructor(scene: Scene);
  73042. private _prepareBuffers;
  73043. private _buildIndexBuffer;
  73044. /**
  73045. * Rebuilds the vertex buffers of the manager.
  73046. * @hidden
  73047. */
  73048. _rebuild(): void;
  73049. /**
  73050. * Prepares a frame to be run through a post process.
  73051. * @param sourceTexture The input texture to the post procesess. (default: null)
  73052. * @param postProcesses An array of post processes to be run. (default: null)
  73053. * @returns True if the post processes were able to be run.
  73054. * @hidden
  73055. */
  73056. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73057. /**
  73058. * Manually render a set of post processes to a texture.
  73059. * @param postProcesses An array of post processes to be run.
  73060. * @param targetTexture The target texture to render to.
  73061. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73062. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73063. * @param lodLevel defines which lod of the texture to render to
  73064. */
  73065. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73066. /**
  73067. * Finalize the result of the output of the postprocesses.
  73068. * @param doNotPresent If true the result will not be displayed to the screen.
  73069. * @param targetTexture The target texture to render to.
  73070. * @param faceIndex The index of the face to bind the target texture to.
  73071. * @param postProcesses The array of post processes to render.
  73072. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73073. * @hidden
  73074. */
  73075. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73076. /**
  73077. * Disposes of the post process manager.
  73078. */
  73079. dispose(): void;
  73080. }
  73081. }
  73082. declare module BABYLON {
  73083. interface AbstractScene {
  73084. /**
  73085. * The list of layers (background and foreground) of the scene
  73086. */
  73087. layers: Array<Layer>;
  73088. }
  73089. /**
  73090. * Defines the layer scene component responsible to manage any layers
  73091. * in a given scene.
  73092. */
  73093. export class LayerSceneComponent implements ISceneComponent {
  73094. /**
  73095. * The component name helpfull to identify the component in the list of scene components.
  73096. */
  73097. readonly name: string;
  73098. /**
  73099. * The scene the component belongs to.
  73100. */
  73101. scene: Scene;
  73102. private _engine;
  73103. /**
  73104. * Creates a new instance of the component for the given scene
  73105. * @param scene Defines the scene to register the component in
  73106. */
  73107. constructor(scene: Scene);
  73108. /**
  73109. * Registers the component in a given scene
  73110. */
  73111. register(): void;
  73112. /**
  73113. * Rebuilds the elements related to this component in case of
  73114. * context lost for instance.
  73115. */
  73116. rebuild(): void;
  73117. /**
  73118. * Disposes the component and the associated ressources.
  73119. */
  73120. dispose(): void;
  73121. private _draw;
  73122. private _drawCameraPredicate;
  73123. private _drawCameraBackground;
  73124. private _drawCameraForeground;
  73125. private _drawRenderTargetPredicate;
  73126. private _drawRenderTargetBackground;
  73127. private _drawRenderTargetForeground;
  73128. }
  73129. }
  73130. declare module BABYLON {
  73131. /** @hidden */
  73132. export var layerPixelShader: {
  73133. name: string;
  73134. shader: string;
  73135. };
  73136. }
  73137. declare module BABYLON {
  73138. /** @hidden */
  73139. export var layerVertexShader: {
  73140. name: string;
  73141. shader: string;
  73142. };
  73143. }
  73144. declare module BABYLON {
  73145. /**
  73146. * This represents a full screen 2d layer.
  73147. * This can be useful to display a picture in the background of your scene for instance.
  73148. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73149. */
  73150. export class Layer {
  73151. /**
  73152. * Define the name of the layer.
  73153. */
  73154. name: string;
  73155. /**
  73156. * Define the texture the layer should display.
  73157. */
  73158. texture: Nullable<Texture>;
  73159. /**
  73160. * Is the layer in background or foreground.
  73161. */
  73162. isBackground: boolean;
  73163. /**
  73164. * Define the color of the layer (instead of texture).
  73165. */
  73166. color: Color4;
  73167. /**
  73168. * Define the scale of the layer in order to zoom in out of the texture.
  73169. */
  73170. scale: Vector2;
  73171. /**
  73172. * Define an offset for the layer in order to shift the texture.
  73173. */
  73174. offset: Vector2;
  73175. /**
  73176. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73177. */
  73178. alphaBlendingMode: number;
  73179. /**
  73180. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73181. * Alpha test will not mix with the background color in case of transparency.
  73182. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73183. */
  73184. alphaTest: boolean;
  73185. /**
  73186. * Define a mask to restrict the layer to only some of the scene cameras.
  73187. */
  73188. layerMask: number;
  73189. /**
  73190. * Define the list of render target the layer is visible into.
  73191. */
  73192. renderTargetTextures: RenderTargetTexture[];
  73193. /**
  73194. * Define if the layer is only used in renderTarget or if it also
  73195. * renders in the main frame buffer of the canvas.
  73196. */
  73197. renderOnlyInRenderTargetTextures: boolean;
  73198. private _scene;
  73199. private _vertexBuffers;
  73200. private _indexBuffer;
  73201. private _effect;
  73202. private _alphaTestEffect;
  73203. /**
  73204. * An event triggered when the layer is disposed.
  73205. */
  73206. onDisposeObservable: Observable<Layer>;
  73207. private _onDisposeObserver;
  73208. /**
  73209. * Back compatibility with callback before the onDisposeObservable existed.
  73210. * The set callback will be triggered when the layer has been disposed.
  73211. */
  73212. onDispose: () => void;
  73213. /**
  73214. * An event triggered before rendering the scene
  73215. */
  73216. onBeforeRenderObservable: Observable<Layer>;
  73217. private _onBeforeRenderObserver;
  73218. /**
  73219. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73220. * The set callback will be triggered just before rendering the layer.
  73221. */
  73222. onBeforeRender: () => void;
  73223. /**
  73224. * An event triggered after rendering the scene
  73225. */
  73226. onAfterRenderObservable: Observable<Layer>;
  73227. private _onAfterRenderObserver;
  73228. /**
  73229. * Back compatibility with callback before the onAfterRenderObservable existed.
  73230. * The set callback will be triggered just after rendering the layer.
  73231. */
  73232. onAfterRender: () => void;
  73233. /**
  73234. * Instantiates a new layer.
  73235. * This represents a full screen 2d layer.
  73236. * This can be useful to display a picture in the background of your scene for instance.
  73237. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73238. * @param name Define the name of the layer in the scene
  73239. * @param imgUrl Define the url of the texture to display in the layer
  73240. * @param scene Define the scene the layer belongs to
  73241. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73242. * @param color Defines a color for the layer
  73243. */
  73244. constructor(
  73245. /**
  73246. * Define the name of the layer.
  73247. */
  73248. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73249. private _createIndexBuffer;
  73250. /** @hidden */
  73251. _rebuild(): void;
  73252. /**
  73253. * Renders the layer in the scene.
  73254. */
  73255. render(): void;
  73256. /**
  73257. * Disposes and releases the associated ressources.
  73258. */
  73259. dispose(): void;
  73260. }
  73261. }
  73262. declare module BABYLON {
  73263. interface AbstractScene {
  73264. /**
  73265. * The list of procedural textures added to the scene
  73266. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73267. */
  73268. proceduralTextures: Array<ProceduralTexture>;
  73269. }
  73270. /**
  73271. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73272. * in a given scene.
  73273. */
  73274. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73275. /**
  73276. * The component name helpfull to identify the component in the list of scene components.
  73277. */
  73278. readonly name: string;
  73279. /**
  73280. * The scene the component belongs to.
  73281. */
  73282. scene: Scene;
  73283. /**
  73284. * Creates a new instance of the component for the given scene
  73285. * @param scene Defines the scene to register the component in
  73286. */
  73287. constructor(scene: Scene);
  73288. /**
  73289. * Registers the component in a given scene
  73290. */
  73291. register(): void;
  73292. /**
  73293. * Rebuilds the elements related to this component in case of
  73294. * context lost for instance.
  73295. */
  73296. rebuild(): void;
  73297. /**
  73298. * Disposes the component and the associated ressources.
  73299. */
  73300. dispose(): void;
  73301. private _beforeClear;
  73302. }
  73303. }
  73304. declare module BABYLON {
  73305. /** @hidden */
  73306. export var proceduralVertexShader: {
  73307. name: string;
  73308. shader: string;
  73309. };
  73310. }
  73311. declare module BABYLON {
  73312. /**
  73313. * 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.
  73314. * This is the base class of any Procedural texture and contains most of the shareable code.
  73315. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73316. */
  73317. export class ProceduralTexture extends Texture {
  73318. isCube: boolean;
  73319. /**
  73320. * Define if the texture is enabled or not (disabled texture will not render)
  73321. */
  73322. isEnabled: boolean;
  73323. /**
  73324. * Define if the texture must be cleared before rendering (default is true)
  73325. */
  73326. autoClear: boolean;
  73327. /**
  73328. * Callback called when the texture is generated
  73329. */
  73330. onGenerated: () => void;
  73331. /**
  73332. * Event raised when the texture is generated
  73333. */
  73334. onGeneratedObservable: Observable<ProceduralTexture>;
  73335. /** @hidden */
  73336. _generateMipMaps: boolean;
  73337. /** @hidden **/
  73338. _effect: Effect;
  73339. /** @hidden */
  73340. _textures: {
  73341. [key: string]: Texture;
  73342. };
  73343. private _size;
  73344. private _currentRefreshId;
  73345. private _refreshRate;
  73346. private _vertexBuffers;
  73347. private _indexBuffer;
  73348. private _uniforms;
  73349. private _samplers;
  73350. private _fragment;
  73351. private _floats;
  73352. private _ints;
  73353. private _floatsArrays;
  73354. private _colors3;
  73355. private _colors4;
  73356. private _vectors2;
  73357. private _vectors3;
  73358. private _matrices;
  73359. private _fallbackTexture;
  73360. private _fallbackTextureUsed;
  73361. private _engine;
  73362. private _cachedDefines;
  73363. private _contentUpdateId;
  73364. private _contentData;
  73365. /**
  73366. * Instantiates a new procedural texture.
  73367. * 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.
  73368. * This is the base class of any Procedural texture and contains most of the shareable code.
  73369. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73370. * @param name Define the name of the texture
  73371. * @param size Define the size of the texture to create
  73372. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73373. * @param scene Define the scene the texture belongs to
  73374. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73375. * @param generateMipMaps Define if the texture should creates mip maps or not
  73376. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73377. */
  73378. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73379. /**
  73380. * The effect that is created when initializing the post process.
  73381. * @returns The created effect corrisponding the the postprocess.
  73382. */
  73383. getEffect(): Effect;
  73384. /**
  73385. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73386. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73387. */
  73388. getContent(): Nullable<ArrayBufferView>;
  73389. private _createIndexBuffer;
  73390. /** @hidden */
  73391. _rebuild(): void;
  73392. /**
  73393. * Resets the texture in order to recreate its associated resources.
  73394. * This can be called in case of context loss
  73395. */
  73396. reset(): void;
  73397. protected _getDefines(): string;
  73398. /**
  73399. * Is the texture ready to be used ? (rendered at least once)
  73400. * @returns true if ready, otherwise, false.
  73401. */
  73402. isReady(): boolean;
  73403. /**
  73404. * Resets the refresh counter of the texture and start bak from scratch.
  73405. * Could be useful to regenerate the texture if it is setup to render only once.
  73406. */
  73407. resetRefreshCounter(): void;
  73408. /**
  73409. * Set the fragment shader to use in order to render the texture.
  73410. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73411. */
  73412. setFragment(fragment: any): void;
  73413. /**
  73414. * Define the refresh rate of the texture or the rendering frequency.
  73415. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73416. */
  73417. refreshRate: number;
  73418. /** @hidden */
  73419. _shouldRender(): boolean;
  73420. /**
  73421. * Get the size the texture is rendering at.
  73422. * @returns the size (texture is always squared)
  73423. */
  73424. getRenderSize(): number;
  73425. /**
  73426. * Resize the texture to new value.
  73427. * @param size Define the new size the texture should have
  73428. * @param generateMipMaps Define whether the new texture should create mip maps
  73429. */
  73430. resize(size: number, generateMipMaps: boolean): void;
  73431. private _checkUniform;
  73432. /**
  73433. * Set a texture in the shader program used to render.
  73434. * @param name Define the name of the uniform samplers as defined in the shader
  73435. * @param texture Define the texture to bind to this sampler
  73436. * @return the texture itself allowing "fluent" like uniform updates
  73437. */
  73438. setTexture(name: string, texture: Texture): ProceduralTexture;
  73439. /**
  73440. * Set a float in the shader.
  73441. * @param name Define the name of the uniform as defined in the shader
  73442. * @param value Define the value to give to the uniform
  73443. * @return the texture itself allowing "fluent" like uniform updates
  73444. */
  73445. setFloat(name: string, value: number): ProceduralTexture;
  73446. /**
  73447. * Set a int in the shader.
  73448. * @param name Define the name of the uniform as defined in the shader
  73449. * @param value Define the value to give to the uniform
  73450. * @return the texture itself allowing "fluent" like uniform updates
  73451. */
  73452. setInt(name: string, value: number): ProceduralTexture;
  73453. /**
  73454. * Set an array of floats in the shader.
  73455. * @param name Define the name of the uniform as defined in the shader
  73456. * @param value Define the value to give to the uniform
  73457. * @return the texture itself allowing "fluent" like uniform updates
  73458. */
  73459. setFloats(name: string, value: number[]): ProceduralTexture;
  73460. /**
  73461. * Set a vec3 in the shader from a Color3.
  73462. * @param name Define the name of the uniform as defined in the shader
  73463. * @param value Define the value to give to the uniform
  73464. * @return the texture itself allowing "fluent" like uniform updates
  73465. */
  73466. setColor3(name: string, value: Color3): ProceduralTexture;
  73467. /**
  73468. * Set a vec4 in the shader from a Color4.
  73469. * @param name Define the name of the uniform as defined in the shader
  73470. * @param value Define the value to give to the uniform
  73471. * @return the texture itself allowing "fluent" like uniform updates
  73472. */
  73473. setColor4(name: string, value: Color4): ProceduralTexture;
  73474. /**
  73475. * Set a vec2 in the shader from a Vector2.
  73476. * @param name Define the name of the uniform as defined in the shader
  73477. * @param value Define the value to give to the uniform
  73478. * @return the texture itself allowing "fluent" like uniform updates
  73479. */
  73480. setVector2(name: string, value: Vector2): ProceduralTexture;
  73481. /**
  73482. * Set a vec3 in the shader from a Vector3.
  73483. * @param name Define the name of the uniform as defined in the shader
  73484. * @param value Define the value to give to the uniform
  73485. * @return the texture itself allowing "fluent" like uniform updates
  73486. */
  73487. setVector3(name: string, value: Vector3): ProceduralTexture;
  73488. /**
  73489. * Set a mat4 in the shader from a MAtrix.
  73490. * @param name Define the name of the uniform as defined in the shader
  73491. * @param value Define the value to give to the uniform
  73492. * @return the texture itself allowing "fluent" like uniform updates
  73493. */
  73494. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73495. /**
  73496. * Render the texture to its associated render target.
  73497. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73498. */
  73499. render(useCameraPostProcess?: boolean): void;
  73500. /**
  73501. * Clone the texture.
  73502. * @returns the cloned texture
  73503. */
  73504. clone(): ProceduralTexture;
  73505. /**
  73506. * Dispose the texture and release its asoociated resources.
  73507. */
  73508. dispose(): void;
  73509. }
  73510. }
  73511. declare module BABYLON {
  73512. /**
  73513. * This represents the base class for particle system in Babylon.
  73514. * 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.
  73515. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73516. * @example https://doc.babylonjs.com/babylon101/particles
  73517. */
  73518. export class BaseParticleSystem {
  73519. /**
  73520. * Source color is added to the destination color without alpha affecting the result
  73521. */
  73522. static BLENDMODE_ONEONE: number;
  73523. /**
  73524. * Blend current color and particle color using particle’s alpha
  73525. */
  73526. static BLENDMODE_STANDARD: number;
  73527. /**
  73528. * Add current color and particle color multiplied by particle’s alpha
  73529. */
  73530. static BLENDMODE_ADD: number;
  73531. /**
  73532. * Multiply current color with particle color
  73533. */
  73534. static BLENDMODE_MULTIPLY: number;
  73535. /**
  73536. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73537. */
  73538. static BLENDMODE_MULTIPLYADD: number;
  73539. /**
  73540. * List of animations used by the particle system.
  73541. */
  73542. animations: Animation[];
  73543. /**
  73544. * The id of the Particle system.
  73545. */
  73546. id: string;
  73547. /**
  73548. * The friendly name of the Particle system.
  73549. */
  73550. name: string;
  73551. /**
  73552. * The rendering group used by the Particle system to chose when to render.
  73553. */
  73554. renderingGroupId: number;
  73555. /**
  73556. * The emitter represents the Mesh or position we are attaching the particle system to.
  73557. */
  73558. emitter: Nullable<AbstractMesh | Vector3>;
  73559. /**
  73560. * The maximum number of particles to emit per frame
  73561. */
  73562. emitRate: number;
  73563. /**
  73564. * If you want to launch only a few particles at once, that can be done, as well.
  73565. */
  73566. manualEmitCount: number;
  73567. /**
  73568. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73569. */
  73570. updateSpeed: number;
  73571. /**
  73572. * The amount of time the particle system is running (depends of the overall update speed).
  73573. */
  73574. targetStopDuration: number;
  73575. /**
  73576. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73577. */
  73578. disposeOnStop: boolean;
  73579. /**
  73580. * Minimum power of emitting particles.
  73581. */
  73582. minEmitPower: number;
  73583. /**
  73584. * Maximum power of emitting particles.
  73585. */
  73586. maxEmitPower: number;
  73587. /**
  73588. * Minimum life time of emitting particles.
  73589. */
  73590. minLifeTime: number;
  73591. /**
  73592. * Maximum life time of emitting particles.
  73593. */
  73594. maxLifeTime: number;
  73595. /**
  73596. * Minimum Size of emitting particles.
  73597. */
  73598. minSize: number;
  73599. /**
  73600. * Maximum Size of emitting particles.
  73601. */
  73602. maxSize: number;
  73603. /**
  73604. * Minimum scale of emitting particles on X axis.
  73605. */
  73606. minScaleX: number;
  73607. /**
  73608. * Maximum scale of emitting particles on X axis.
  73609. */
  73610. maxScaleX: number;
  73611. /**
  73612. * Minimum scale of emitting particles on Y axis.
  73613. */
  73614. minScaleY: number;
  73615. /**
  73616. * Maximum scale of emitting particles on Y axis.
  73617. */
  73618. maxScaleY: number;
  73619. /**
  73620. * Gets or sets the minimal initial rotation in radians.
  73621. */
  73622. minInitialRotation: number;
  73623. /**
  73624. * Gets or sets the maximal initial rotation in radians.
  73625. */
  73626. maxInitialRotation: number;
  73627. /**
  73628. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73629. */
  73630. minAngularSpeed: number;
  73631. /**
  73632. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73633. */
  73634. maxAngularSpeed: number;
  73635. /**
  73636. * The texture used to render each particle. (this can be a spritesheet)
  73637. */
  73638. particleTexture: Nullable<Texture>;
  73639. /**
  73640. * The layer mask we are rendering the particles through.
  73641. */
  73642. layerMask: number;
  73643. /**
  73644. * This can help using your own shader to render the particle system.
  73645. * The according effect will be created
  73646. */
  73647. customShader: any;
  73648. /**
  73649. * By default particle system starts as soon as they are created. This prevents the
  73650. * automatic start to happen and let you decide when to start emitting particles.
  73651. */
  73652. preventAutoStart: boolean;
  73653. private _noiseTexture;
  73654. /**
  73655. * Gets or sets a texture used to add random noise to particle positions
  73656. */
  73657. noiseTexture: Nullable<ProceduralTexture>;
  73658. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73659. noiseStrength: Vector3;
  73660. /**
  73661. * Callback triggered when the particle animation is ending.
  73662. */
  73663. onAnimationEnd: Nullable<() => void>;
  73664. /**
  73665. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73666. */
  73667. blendMode: number;
  73668. /**
  73669. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73670. * to override the particles.
  73671. */
  73672. forceDepthWrite: boolean;
  73673. /** 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 */
  73674. preWarmCycles: number;
  73675. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73676. preWarmStepOffset: number;
  73677. /**
  73678. * 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)
  73679. */
  73680. spriteCellChangeSpeed: number;
  73681. /**
  73682. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73683. */
  73684. startSpriteCellID: number;
  73685. /**
  73686. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73687. */
  73688. endSpriteCellID: number;
  73689. /**
  73690. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73691. */
  73692. spriteCellWidth: number;
  73693. /**
  73694. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73695. */
  73696. spriteCellHeight: number;
  73697. /**
  73698. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73699. */
  73700. spriteRandomStartCell: boolean;
  73701. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73702. translationPivot: Vector2;
  73703. /** @hidden */
  73704. protected _isAnimationSheetEnabled: boolean;
  73705. /**
  73706. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73707. */
  73708. beginAnimationOnStart: boolean;
  73709. /**
  73710. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73711. */
  73712. beginAnimationFrom: number;
  73713. /**
  73714. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73715. */
  73716. beginAnimationTo: number;
  73717. /**
  73718. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73719. */
  73720. beginAnimationLoop: boolean;
  73721. /**
  73722. * Gets or sets a world offset applied to all particles
  73723. */
  73724. worldOffset: Vector3;
  73725. /**
  73726. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73727. */
  73728. isAnimationSheetEnabled: boolean;
  73729. /**
  73730. * Get hosting scene
  73731. * @returns the scene
  73732. */
  73733. getScene(): Scene;
  73734. /**
  73735. * You can use gravity if you want to give an orientation to your particles.
  73736. */
  73737. gravity: Vector3;
  73738. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73739. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73740. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73741. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73742. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73743. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73744. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73745. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73746. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73747. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73748. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73749. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73750. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73751. /**
  73752. * Defines the delay in milliseconds before starting the system (0 by default)
  73753. */
  73754. startDelay: number;
  73755. /**
  73756. * Gets the current list of drag gradients.
  73757. * You must use addDragGradient and removeDragGradient to udpate this list
  73758. * @returns the list of drag gradients
  73759. */
  73760. getDragGradients(): Nullable<Array<FactorGradient>>;
  73761. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73762. limitVelocityDamping: number;
  73763. /**
  73764. * Gets the current list of limit velocity gradients.
  73765. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73766. * @returns the list of limit velocity gradients
  73767. */
  73768. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73769. /**
  73770. * Gets the current list of color gradients.
  73771. * You must use addColorGradient and removeColorGradient to udpate this list
  73772. * @returns the list of color gradients
  73773. */
  73774. getColorGradients(): Nullable<Array<ColorGradient>>;
  73775. /**
  73776. * Gets the current list of size gradients.
  73777. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73778. * @returns the list of size gradients
  73779. */
  73780. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73781. /**
  73782. * Gets the current list of color remap gradients.
  73783. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73784. * @returns the list of color remap gradients
  73785. */
  73786. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73787. /**
  73788. * Gets the current list of alpha remap gradients.
  73789. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73790. * @returns the list of alpha remap gradients
  73791. */
  73792. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73793. /**
  73794. * Gets the current list of life time gradients.
  73795. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73796. * @returns the list of life time gradients
  73797. */
  73798. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73799. /**
  73800. * Gets the current list of angular speed gradients.
  73801. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73802. * @returns the list of angular speed gradients
  73803. */
  73804. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73805. /**
  73806. * Gets the current list of velocity gradients.
  73807. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73808. * @returns the list of velocity gradients
  73809. */
  73810. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73811. /**
  73812. * Gets the current list of start size gradients.
  73813. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73814. * @returns the list of start size gradients
  73815. */
  73816. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73817. /**
  73818. * Gets the current list of emit rate gradients.
  73819. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73820. * @returns the list of emit rate gradients
  73821. */
  73822. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73823. /**
  73824. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73825. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73826. */
  73827. direction1: Vector3;
  73828. /**
  73829. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73830. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73831. */
  73832. direction2: Vector3;
  73833. /**
  73834. * 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.
  73835. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73836. */
  73837. minEmitBox: Vector3;
  73838. /**
  73839. * 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.
  73840. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73841. */
  73842. maxEmitBox: Vector3;
  73843. /**
  73844. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73845. */
  73846. color1: Color4;
  73847. /**
  73848. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73849. */
  73850. color2: Color4;
  73851. /**
  73852. * Color the particle will have at the end of its lifetime
  73853. */
  73854. colorDead: Color4;
  73855. /**
  73856. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73857. */
  73858. textureMask: Color4;
  73859. /**
  73860. * The particle emitter type defines the emitter used by the particle system.
  73861. * It can be for example box, sphere, or cone...
  73862. */
  73863. particleEmitterType: IParticleEmitterType;
  73864. /** @hidden */
  73865. _isSubEmitter: boolean;
  73866. /**
  73867. * Gets or sets the billboard mode to use when isBillboardBased = true.
  73868. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  73869. */
  73870. billboardMode: number;
  73871. protected _isBillboardBased: boolean;
  73872. /**
  73873. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  73874. */
  73875. isBillboardBased: boolean;
  73876. /**
  73877. * The scene the particle system belongs to.
  73878. */
  73879. protected _scene: Scene;
  73880. /**
  73881. * Local cache of defines for image processing.
  73882. */
  73883. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  73884. /**
  73885. * Default configuration related to image processing available in the standard Material.
  73886. */
  73887. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  73888. /**
  73889. * Gets the image processing configuration used either in this material.
  73890. */
  73891. /**
  73892. * Sets the Default image processing configuration used either in the this material.
  73893. *
  73894. * If sets to null, the scene one is in use.
  73895. */
  73896. imageProcessingConfiguration: ImageProcessingConfiguration;
  73897. /**
  73898. * Attaches a new image processing configuration to the Standard Material.
  73899. * @param configuration
  73900. */
  73901. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  73902. /** @hidden */
  73903. protected _reset(): void;
  73904. /** @hidden */
  73905. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  73906. /**
  73907. * Instantiates a particle system.
  73908. * 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.
  73909. * @param name The name of the particle system
  73910. */
  73911. constructor(name: string);
  73912. /**
  73913. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  73914. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73915. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73916. * @returns the emitter
  73917. */
  73918. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  73919. /**
  73920. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  73921. * @param radius The radius of the hemisphere to emit from
  73922. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73923. * @returns the emitter
  73924. */
  73925. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  73926. /**
  73927. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  73928. * @param radius The radius of the sphere to emit from
  73929. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  73930. * @returns the emitter
  73931. */
  73932. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  73933. /**
  73934. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  73935. * @param radius The radius of the sphere to emit from
  73936. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  73937. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  73938. * @returns the emitter
  73939. */
  73940. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  73941. /**
  73942. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  73943. * @param radius The radius of the emission cylinder
  73944. * @param height The height of the emission cylinder
  73945. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  73946. * @param directionRandomizer How much to randomize the particle direction [0-1]
  73947. * @returns the emitter
  73948. */
  73949. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  73950. /**
  73951. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  73952. * @param radius The radius of the cylinder to emit from
  73953. * @param height The height of the emission cylinder
  73954. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  73955. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  73956. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  73957. * @returns the emitter
  73958. */
  73959. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  73960. /**
  73961. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  73962. * @param radius The radius of the cone to emit from
  73963. * @param angle The base angle of the cone
  73964. * @returns the emitter
  73965. */
  73966. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  73967. /**
  73968. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  73969. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  73970. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  73971. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73972. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  73973. * @returns the emitter
  73974. */
  73975. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  73976. }
  73977. }
  73978. declare module BABYLON {
  73979. /**
  73980. * Type of sub emitter
  73981. */
  73982. export enum SubEmitterType {
  73983. /**
  73984. * Attached to the particle over it's lifetime
  73985. */
  73986. ATTACHED = 0,
  73987. /**
  73988. * Created when the particle dies
  73989. */
  73990. END = 1
  73991. }
  73992. /**
  73993. * Sub emitter class used to emit particles from an existing particle
  73994. */
  73995. export class SubEmitter {
  73996. /**
  73997. * the particle system to be used by the sub emitter
  73998. */
  73999. particleSystem: ParticleSystem;
  74000. /**
  74001. * Type of the submitter (Default: END)
  74002. */
  74003. type: SubEmitterType;
  74004. /**
  74005. * 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)
  74006. * Note: This only is supported when using an emitter of type Mesh
  74007. */
  74008. inheritDirection: boolean;
  74009. /**
  74010. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74011. */
  74012. inheritedVelocityAmount: number;
  74013. /**
  74014. * Creates a sub emitter
  74015. * @param particleSystem the particle system to be used by the sub emitter
  74016. */
  74017. constructor(
  74018. /**
  74019. * the particle system to be used by the sub emitter
  74020. */
  74021. particleSystem: ParticleSystem);
  74022. /**
  74023. * Clones the sub emitter
  74024. * @returns the cloned sub emitter
  74025. */
  74026. clone(): SubEmitter;
  74027. /**
  74028. * Serialize current object to a JSON object
  74029. * @returns the serialized object
  74030. */
  74031. serialize(): any;
  74032. /** @hidden */
  74033. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74034. /**
  74035. * Creates a new SubEmitter from a serialized JSON version
  74036. * @param serializationObject defines the JSON object to read from
  74037. * @param scene defines the hosting scene
  74038. * @param rootUrl defines the rootUrl for data loading
  74039. * @returns a new SubEmitter
  74040. */
  74041. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74042. /** Release associated resources */
  74043. dispose(): void;
  74044. }
  74045. }
  74046. declare module BABYLON {
  74047. /** @hidden */
  74048. export var clipPlaneFragmentDeclaration: {
  74049. name: string;
  74050. shader: string;
  74051. };
  74052. }
  74053. declare module BABYLON {
  74054. /** @hidden */
  74055. export var imageProcessingDeclaration: {
  74056. name: string;
  74057. shader: string;
  74058. };
  74059. }
  74060. declare module BABYLON {
  74061. /** @hidden */
  74062. export var imageProcessingFunctions: {
  74063. name: string;
  74064. shader: string;
  74065. };
  74066. }
  74067. declare module BABYLON {
  74068. /** @hidden */
  74069. export var clipPlaneFragment: {
  74070. name: string;
  74071. shader: string;
  74072. };
  74073. }
  74074. declare module BABYLON {
  74075. /** @hidden */
  74076. export var particlesPixelShader: {
  74077. name: string;
  74078. shader: string;
  74079. };
  74080. }
  74081. declare module BABYLON {
  74082. /** @hidden */
  74083. export var clipPlaneVertexDeclaration: {
  74084. name: string;
  74085. shader: string;
  74086. };
  74087. }
  74088. declare module BABYLON {
  74089. /** @hidden */
  74090. export var clipPlaneVertex: {
  74091. name: string;
  74092. shader: string;
  74093. };
  74094. }
  74095. declare module BABYLON {
  74096. /** @hidden */
  74097. export var particlesVertexShader: {
  74098. name: string;
  74099. shader: string;
  74100. };
  74101. }
  74102. declare module BABYLON {
  74103. /**
  74104. * This represents a particle system in Babylon.
  74105. * 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.
  74106. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74107. * @example https://doc.babylonjs.com/babylon101/particles
  74108. */
  74109. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74110. /**
  74111. * Billboard mode will only apply to Y axis
  74112. */
  74113. static readonly BILLBOARDMODE_Y: number;
  74114. /**
  74115. * Billboard mode will apply to all axes
  74116. */
  74117. static readonly BILLBOARDMODE_ALL: number;
  74118. /**
  74119. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74120. */
  74121. static readonly BILLBOARDMODE_STRETCHED: number;
  74122. /**
  74123. * This function can be defined to provide custom update for active particles.
  74124. * This function will be called instead of regular update (age, position, color, etc.).
  74125. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74126. */
  74127. updateFunction: (particles: Particle[]) => void;
  74128. private _emitterWorldMatrix;
  74129. /**
  74130. * This function can be defined to specify initial direction for every new particle.
  74131. * It by default use the emitterType defined function
  74132. */
  74133. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74134. /**
  74135. * This function can be defined to specify initial position for every new particle.
  74136. * It by default use the emitterType defined function
  74137. */
  74138. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74139. /**
  74140. * @hidden
  74141. */
  74142. _inheritedVelocityOffset: Vector3;
  74143. /**
  74144. * An event triggered when the system is disposed
  74145. */
  74146. onDisposeObservable: Observable<ParticleSystem>;
  74147. private _onDisposeObserver;
  74148. /**
  74149. * Sets a callback that will be triggered when the system is disposed
  74150. */
  74151. onDispose: () => void;
  74152. private _particles;
  74153. private _epsilon;
  74154. private _capacity;
  74155. private _stockParticles;
  74156. private _newPartsExcess;
  74157. private _vertexData;
  74158. private _vertexBuffer;
  74159. private _vertexBuffers;
  74160. private _spriteBuffer;
  74161. private _indexBuffer;
  74162. private _effect;
  74163. private _customEffect;
  74164. private _cachedDefines;
  74165. private _scaledColorStep;
  74166. private _colorDiff;
  74167. private _scaledDirection;
  74168. private _scaledGravity;
  74169. private _currentRenderId;
  74170. private _alive;
  74171. private _useInstancing;
  74172. private _started;
  74173. private _stopped;
  74174. private _actualFrame;
  74175. private _scaledUpdateSpeed;
  74176. private _vertexBufferSize;
  74177. /** @hidden */
  74178. _currentEmitRateGradient: Nullable<FactorGradient>;
  74179. /** @hidden */
  74180. _currentEmitRate1: number;
  74181. /** @hidden */
  74182. _currentEmitRate2: number;
  74183. /** @hidden */
  74184. _currentStartSizeGradient: Nullable<FactorGradient>;
  74185. /** @hidden */
  74186. _currentStartSize1: number;
  74187. /** @hidden */
  74188. _currentStartSize2: number;
  74189. private readonly _rawTextureWidth;
  74190. private _rampGradientsTexture;
  74191. private _useRampGradients;
  74192. /** Gets or sets a boolean indicating that ramp gradients must be used
  74193. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74194. */
  74195. useRampGradients: boolean;
  74196. /**
  74197. * 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.
  74198. * 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: [])
  74199. */
  74200. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74201. private _subEmitters;
  74202. /**
  74203. * @hidden
  74204. * If the particle systems emitter should be disposed when the particle system is disposed
  74205. */
  74206. _disposeEmitterOnDispose: boolean;
  74207. /**
  74208. * The current active Sub-systems, this property is used by the root particle system only.
  74209. */
  74210. activeSubSystems: Array<ParticleSystem>;
  74211. private _rootParticleSystem;
  74212. /**
  74213. * Gets the current list of active particles
  74214. */
  74215. readonly particles: Particle[];
  74216. /**
  74217. * Returns the string "ParticleSystem"
  74218. * @returns a string containing the class name
  74219. */
  74220. getClassName(): string;
  74221. /**
  74222. * Instantiates a particle system.
  74223. * 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.
  74224. * @param name The name of the particle system
  74225. * @param capacity The max number of particles alive at the same time
  74226. * @param scene The scene the particle system belongs to
  74227. * @param customEffect a custom effect used to change the way particles are rendered by default
  74228. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74229. * @param epsilon Offset used to render the particles
  74230. */
  74231. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74232. private _addFactorGradient;
  74233. private _removeFactorGradient;
  74234. /**
  74235. * Adds a new life time gradient
  74236. * @param gradient defines the gradient to use (between 0 and 1)
  74237. * @param factor defines the life time factor to affect to the specified gradient
  74238. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74239. * @returns the current particle system
  74240. */
  74241. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74242. /**
  74243. * Remove a specific life time gradient
  74244. * @param gradient defines the gradient to remove
  74245. * @returns the current particle system
  74246. */
  74247. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74248. /**
  74249. * Adds a new size gradient
  74250. * @param gradient defines the gradient to use (between 0 and 1)
  74251. * @param factor defines the size factor to affect to the specified gradient
  74252. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74253. * @returns the current particle system
  74254. */
  74255. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74256. /**
  74257. * Remove a specific size gradient
  74258. * @param gradient defines the gradient to remove
  74259. * @returns the current particle system
  74260. */
  74261. removeSizeGradient(gradient: number): IParticleSystem;
  74262. /**
  74263. * Adds a new color remap gradient
  74264. * @param gradient defines the gradient to use (between 0 and 1)
  74265. * @param min defines the color remap minimal range
  74266. * @param max defines the color remap maximal range
  74267. * @returns the current particle system
  74268. */
  74269. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74270. /**
  74271. * Remove a specific color remap gradient
  74272. * @param gradient defines the gradient to remove
  74273. * @returns the current particle system
  74274. */
  74275. removeColorRemapGradient(gradient: number): IParticleSystem;
  74276. /**
  74277. * Adds a new alpha remap gradient
  74278. * @param gradient defines the gradient to use (between 0 and 1)
  74279. * @param min defines the alpha remap minimal range
  74280. * @param max defines the alpha remap maximal range
  74281. * @returns the current particle system
  74282. */
  74283. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74284. /**
  74285. * Remove a specific alpha remap gradient
  74286. * @param gradient defines the gradient to remove
  74287. * @returns the current particle system
  74288. */
  74289. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74290. /**
  74291. * Adds a new angular speed gradient
  74292. * @param gradient defines the gradient to use (between 0 and 1)
  74293. * @param factor defines the angular speed to affect to the specified gradient
  74294. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74295. * @returns the current particle system
  74296. */
  74297. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74298. /**
  74299. * Remove a specific angular speed gradient
  74300. * @param gradient defines the gradient to remove
  74301. * @returns the current particle system
  74302. */
  74303. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74304. /**
  74305. * Adds a new velocity gradient
  74306. * @param gradient defines the gradient to use (between 0 and 1)
  74307. * @param factor defines the velocity to affect to the specified gradient
  74308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74309. * @returns the current particle system
  74310. */
  74311. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74312. /**
  74313. * Remove a specific velocity gradient
  74314. * @param gradient defines the gradient to remove
  74315. * @returns the current particle system
  74316. */
  74317. removeVelocityGradient(gradient: number): IParticleSystem;
  74318. /**
  74319. * Adds a new limit velocity gradient
  74320. * @param gradient defines the gradient to use (between 0 and 1)
  74321. * @param factor defines the limit velocity value to affect to the specified gradient
  74322. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74323. * @returns the current particle system
  74324. */
  74325. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74326. /**
  74327. * Remove a specific limit velocity gradient
  74328. * @param gradient defines the gradient to remove
  74329. * @returns the current particle system
  74330. */
  74331. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74332. /**
  74333. * Adds a new drag gradient
  74334. * @param gradient defines the gradient to use (between 0 and 1)
  74335. * @param factor defines the drag value to affect to the specified gradient
  74336. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74337. * @returns the current particle system
  74338. */
  74339. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74340. /**
  74341. * Remove a specific drag gradient
  74342. * @param gradient defines the gradient to remove
  74343. * @returns the current particle system
  74344. */
  74345. removeDragGradient(gradient: number): IParticleSystem;
  74346. /**
  74347. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74348. * @param gradient defines the gradient to use (between 0 and 1)
  74349. * @param factor defines the emit rate value to affect to the specified gradient
  74350. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74351. * @returns the current particle system
  74352. */
  74353. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74354. /**
  74355. * Remove a specific emit rate gradient
  74356. * @param gradient defines the gradient to remove
  74357. * @returns the current particle system
  74358. */
  74359. removeEmitRateGradient(gradient: number): IParticleSystem;
  74360. /**
  74361. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74362. * @param gradient defines the gradient to use (between 0 and 1)
  74363. * @param factor defines the start size value to affect to the specified gradient
  74364. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74365. * @returns the current particle system
  74366. */
  74367. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74368. /**
  74369. * Remove a specific start size gradient
  74370. * @param gradient defines the gradient to remove
  74371. * @returns the current particle system
  74372. */
  74373. removeStartSizeGradient(gradient: number): IParticleSystem;
  74374. private _createRampGradientTexture;
  74375. /**
  74376. * Gets the current list of ramp gradients.
  74377. * You must use addRampGradient and removeRampGradient to udpate this list
  74378. * @returns the list of ramp gradients
  74379. */
  74380. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74381. /**
  74382. * Adds a new ramp gradient used to remap particle colors
  74383. * @param gradient defines the gradient to use (between 0 and 1)
  74384. * @param color defines the color to affect to the specified gradient
  74385. * @returns the current particle system
  74386. */
  74387. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74388. /**
  74389. * Remove a specific ramp gradient
  74390. * @param gradient defines the gradient to remove
  74391. * @returns the current particle system
  74392. */
  74393. removeRampGradient(gradient: number): ParticleSystem;
  74394. /**
  74395. * Adds a new color gradient
  74396. * @param gradient defines the gradient to use (between 0 and 1)
  74397. * @param color1 defines the color to affect to the specified gradient
  74398. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74399. * @returns this particle system
  74400. */
  74401. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74402. /**
  74403. * Remove a specific color gradient
  74404. * @param gradient defines the gradient to remove
  74405. * @returns this particle system
  74406. */
  74407. removeColorGradient(gradient: number): IParticleSystem;
  74408. private _fetchR;
  74409. protected _reset(): void;
  74410. private _resetEffect;
  74411. private _createVertexBuffers;
  74412. private _createIndexBuffer;
  74413. /**
  74414. * Gets the maximum number of particles active at the same time.
  74415. * @returns The max number of active particles.
  74416. */
  74417. getCapacity(): number;
  74418. /**
  74419. * Gets whether there are still active particles in the system.
  74420. * @returns True if it is alive, otherwise false.
  74421. */
  74422. isAlive(): boolean;
  74423. /**
  74424. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74425. * @returns True if it has been started, otherwise false.
  74426. */
  74427. isStarted(): boolean;
  74428. private _prepareSubEmitterInternalArray;
  74429. /**
  74430. * Starts the particle system and begins to emit
  74431. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74432. */
  74433. start(delay?: number): void;
  74434. /**
  74435. * Stops the particle system.
  74436. * @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.
  74437. */
  74438. stop(stopSubEmitters?: boolean): void;
  74439. /**
  74440. * Remove all active particles
  74441. */
  74442. reset(): void;
  74443. /**
  74444. * @hidden (for internal use only)
  74445. */
  74446. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74447. /**
  74448. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74449. * Its lifetime will start back at 0.
  74450. */
  74451. recycleParticle: (particle: Particle) => void;
  74452. private _stopSubEmitters;
  74453. private _createParticle;
  74454. private _removeFromRoot;
  74455. private _emitFromParticle;
  74456. private _update;
  74457. /** @hidden */
  74458. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74459. /** @hidden */
  74460. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74461. /** @hidden */
  74462. private _getEffect;
  74463. /**
  74464. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74465. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74466. */
  74467. animate(preWarmOnly?: boolean): void;
  74468. private _appendParticleVertices;
  74469. /**
  74470. * Rebuilds the particle system.
  74471. */
  74472. rebuild(): void;
  74473. /**
  74474. * Is this system ready to be used/rendered
  74475. * @return true if the system is ready
  74476. */
  74477. isReady(): boolean;
  74478. private _render;
  74479. /**
  74480. * Renders the particle system in its current state.
  74481. * @returns the current number of particles
  74482. */
  74483. render(): number;
  74484. /**
  74485. * Disposes the particle system and free the associated resources
  74486. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74487. */
  74488. dispose(disposeTexture?: boolean): void;
  74489. /**
  74490. * Clones the particle system.
  74491. * @param name The name of the cloned object
  74492. * @param newEmitter The new emitter to use
  74493. * @returns the cloned particle system
  74494. */
  74495. clone(name: string, newEmitter: any): ParticleSystem;
  74496. /**
  74497. * Serializes the particle system to a JSON object.
  74498. * @returns the JSON object
  74499. */
  74500. serialize(): any;
  74501. /** @hidden */
  74502. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74503. /** @hidden */
  74504. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74505. /**
  74506. * Parses a JSON object to create a particle system.
  74507. * @param parsedParticleSystem The JSON object to parse
  74508. * @param scene The scene to create the particle system in
  74509. * @param rootUrl The root url to use to load external dependencies like texture
  74510. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74511. * @returns the Parsed particle system
  74512. */
  74513. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74514. }
  74515. }
  74516. declare module BABYLON {
  74517. /**
  74518. * A particle represents one of the element emitted by a particle system.
  74519. * This is mainly define by its coordinates, direction, velocity and age.
  74520. */
  74521. export class Particle {
  74522. /**
  74523. * The particle system the particle belongs to.
  74524. */
  74525. particleSystem: ParticleSystem;
  74526. private static _Count;
  74527. /**
  74528. * Unique ID of the particle
  74529. */
  74530. id: number;
  74531. /**
  74532. * The world position of the particle in the scene.
  74533. */
  74534. position: Vector3;
  74535. /**
  74536. * The world direction of the particle in the scene.
  74537. */
  74538. direction: Vector3;
  74539. /**
  74540. * The color of the particle.
  74541. */
  74542. color: Color4;
  74543. /**
  74544. * The color change of the particle per step.
  74545. */
  74546. colorStep: Color4;
  74547. /**
  74548. * Defines how long will the life of the particle be.
  74549. */
  74550. lifeTime: number;
  74551. /**
  74552. * The current age of the particle.
  74553. */
  74554. age: number;
  74555. /**
  74556. * The current size of the particle.
  74557. */
  74558. size: number;
  74559. /**
  74560. * The current scale of the particle.
  74561. */
  74562. scale: Vector2;
  74563. /**
  74564. * The current angle of the particle.
  74565. */
  74566. angle: number;
  74567. /**
  74568. * Defines how fast is the angle changing.
  74569. */
  74570. angularSpeed: number;
  74571. /**
  74572. * Defines the cell index used by the particle to be rendered from a sprite.
  74573. */
  74574. cellIndex: number;
  74575. /**
  74576. * The information required to support color remapping
  74577. */
  74578. remapData: Vector4;
  74579. /** @hidden */
  74580. _randomCellOffset?: number;
  74581. /** @hidden */
  74582. _initialDirection: Nullable<Vector3>;
  74583. /** @hidden */
  74584. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74585. /** @hidden */
  74586. _initialStartSpriteCellID: number;
  74587. /** @hidden */
  74588. _initialEndSpriteCellID: number;
  74589. /** @hidden */
  74590. _currentColorGradient: Nullable<ColorGradient>;
  74591. /** @hidden */
  74592. _currentColor1: Color4;
  74593. /** @hidden */
  74594. _currentColor2: Color4;
  74595. /** @hidden */
  74596. _currentSizeGradient: Nullable<FactorGradient>;
  74597. /** @hidden */
  74598. _currentSize1: number;
  74599. /** @hidden */
  74600. _currentSize2: number;
  74601. /** @hidden */
  74602. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74603. /** @hidden */
  74604. _currentAngularSpeed1: number;
  74605. /** @hidden */
  74606. _currentAngularSpeed2: number;
  74607. /** @hidden */
  74608. _currentVelocityGradient: Nullable<FactorGradient>;
  74609. /** @hidden */
  74610. _currentVelocity1: number;
  74611. /** @hidden */
  74612. _currentVelocity2: number;
  74613. /** @hidden */
  74614. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74615. /** @hidden */
  74616. _currentLimitVelocity1: number;
  74617. /** @hidden */
  74618. _currentLimitVelocity2: number;
  74619. /** @hidden */
  74620. _currentDragGradient: Nullable<FactorGradient>;
  74621. /** @hidden */
  74622. _currentDrag1: number;
  74623. /** @hidden */
  74624. _currentDrag2: number;
  74625. /** @hidden */
  74626. _randomNoiseCoordinates1: Vector3;
  74627. /** @hidden */
  74628. _randomNoiseCoordinates2: Vector3;
  74629. /**
  74630. * Creates a new instance Particle
  74631. * @param particleSystem the particle system the particle belongs to
  74632. */
  74633. constructor(
  74634. /**
  74635. * The particle system the particle belongs to.
  74636. */
  74637. particleSystem: ParticleSystem);
  74638. private updateCellInfoFromSystem;
  74639. /**
  74640. * Defines how the sprite cell index is updated for the particle
  74641. */
  74642. updateCellIndex(): void;
  74643. /** @hidden */
  74644. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74645. /** @hidden */
  74646. _inheritParticleInfoToSubEmitters(): void;
  74647. /** @hidden */
  74648. _reset(): void;
  74649. /**
  74650. * Copy the properties of particle to another one.
  74651. * @param other the particle to copy the information to.
  74652. */
  74653. copyTo(other: Particle): void;
  74654. }
  74655. }
  74656. declare module BABYLON {
  74657. /**
  74658. * Particle emitter represents a volume emitting particles.
  74659. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74660. */
  74661. export interface IParticleEmitterType {
  74662. /**
  74663. * Called by the particle System when the direction is computed for the created particle.
  74664. * @param worldMatrix is the world matrix of the particle system
  74665. * @param directionToUpdate is the direction vector to update with the result
  74666. * @param particle is the particle we are computed the direction for
  74667. */
  74668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74669. /**
  74670. * Called by the particle System when the position is computed for the created particle.
  74671. * @param worldMatrix is the world matrix of the particle system
  74672. * @param positionToUpdate is the position vector to update with the result
  74673. * @param particle is the particle we are computed the position for
  74674. */
  74675. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74676. /**
  74677. * Clones the current emitter and returns a copy of it
  74678. * @returns the new emitter
  74679. */
  74680. clone(): IParticleEmitterType;
  74681. /**
  74682. * Called by the GPUParticleSystem to setup the update shader
  74683. * @param effect defines the update shader
  74684. */
  74685. applyToShader(effect: Effect): void;
  74686. /**
  74687. * Returns a string to use to update the GPU particles update shader
  74688. * @returns the effect defines string
  74689. */
  74690. getEffectDefines(): string;
  74691. /**
  74692. * Returns a string representing the class name
  74693. * @returns a string containing the class name
  74694. */
  74695. getClassName(): string;
  74696. /**
  74697. * Serializes the particle system to a JSON object.
  74698. * @returns the JSON object
  74699. */
  74700. serialize(): any;
  74701. /**
  74702. * Parse properties from a JSON object
  74703. * @param serializationObject defines the JSON object
  74704. */
  74705. parse(serializationObject: any): void;
  74706. }
  74707. }
  74708. declare module BABYLON {
  74709. /**
  74710. * Particle emitter emitting particles from the inside of a box.
  74711. * It emits the particles randomly between 2 given directions.
  74712. */
  74713. export class BoxParticleEmitter implements IParticleEmitterType {
  74714. /**
  74715. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74716. */
  74717. direction1: Vector3;
  74718. /**
  74719. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74720. */
  74721. direction2: Vector3;
  74722. /**
  74723. * 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.
  74724. */
  74725. minEmitBox: Vector3;
  74726. /**
  74727. * 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.
  74728. */
  74729. maxEmitBox: Vector3;
  74730. /**
  74731. * Creates a new instance BoxParticleEmitter
  74732. */
  74733. constructor();
  74734. /**
  74735. * Called by the particle System when the direction is computed for the created particle.
  74736. * @param worldMatrix is the world matrix of the particle system
  74737. * @param directionToUpdate is the direction vector to update with the result
  74738. * @param particle is the particle we are computed the direction for
  74739. */
  74740. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74741. /**
  74742. * Called by the particle System when the position is computed for the created particle.
  74743. * @param worldMatrix is the world matrix of the particle system
  74744. * @param positionToUpdate is the position vector to update with the result
  74745. * @param particle is the particle we are computed the position for
  74746. */
  74747. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74748. /**
  74749. * Clones the current emitter and returns a copy of it
  74750. * @returns the new emitter
  74751. */
  74752. clone(): BoxParticleEmitter;
  74753. /**
  74754. * Called by the GPUParticleSystem to setup the update shader
  74755. * @param effect defines the update shader
  74756. */
  74757. applyToShader(effect: Effect): void;
  74758. /**
  74759. * Returns a string to use to update the GPU particles update shader
  74760. * @returns a string containng the defines string
  74761. */
  74762. getEffectDefines(): string;
  74763. /**
  74764. * Returns the string "BoxParticleEmitter"
  74765. * @returns a string containing the class name
  74766. */
  74767. getClassName(): string;
  74768. /**
  74769. * Serializes the particle system to a JSON object.
  74770. * @returns the JSON object
  74771. */
  74772. serialize(): any;
  74773. /**
  74774. * Parse properties from a JSON object
  74775. * @param serializationObject defines the JSON object
  74776. */
  74777. parse(serializationObject: any): void;
  74778. }
  74779. }
  74780. declare module BABYLON {
  74781. /**
  74782. * Particle emitter emitting particles from the inside of a cone.
  74783. * It emits the particles alongside the cone volume from the base to the particle.
  74784. * The emission direction might be randomized.
  74785. */
  74786. export class ConeParticleEmitter implements IParticleEmitterType {
  74787. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74788. directionRandomizer: number;
  74789. private _radius;
  74790. private _angle;
  74791. private _height;
  74792. /**
  74793. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74794. */
  74795. radiusRange: number;
  74796. /**
  74797. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74798. */
  74799. heightRange: number;
  74800. /**
  74801. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74802. */
  74803. emitFromSpawnPointOnly: boolean;
  74804. /**
  74805. * Gets or sets the radius of the emission cone
  74806. */
  74807. radius: number;
  74808. /**
  74809. * Gets or sets the angle of the emission cone
  74810. */
  74811. angle: number;
  74812. private _buildHeight;
  74813. /**
  74814. * Creates a new instance ConeParticleEmitter
  74815. * @param radius the radius of the emission cone (1 by default)
  74816. * @param angle the cone base angle (PI by default)
  74817. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74818. */
  74819. constructor(radius?: number, angle?: number,
  74820. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74821. directionRandomizer?: number);
  74822. /**
  74823. * Called by the particle System when the direction is computed for the created particle.
  74824. * @param worldMatrix is the world matrix of the particle system
  74825. * @param directionToUpdate is the direction vector to update with the result
  74826. * @param particle is the particle we are computed the direction for
  74827. */
  74828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74829. /**
  74830. * Called by the particle System when the position is computed for the created particle.
  74831. * @param worldMatrix is the world matrix of the particle system
  74832. * @param positionToUpdate is the position vector to update with the result
  74833. * @param particle is the particle we are computed the position for
  74834. */
  74835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74836. /**
  74837. * Clones the current emitter and returns a copy of it
  74838. * @returns the new emitter
  74839. */
  74840. clone(): ConeParticleEmitter;
  74841. /**
  74842. * Called by the GPUParticleSystem to setup the update shader
  74843. * @param effect defines the update shader
  74844. */
  74845. applyToShader(effect: Effect): void;
  74846. /**
  74847. * Returns a string to use to update the GPU particles update shader
  74848. * @returns a string containng the defines string
  74849. */
  74850. getEffectDefines(): string;
  74851. /**
  74852. * Returns the string "ConeParticleEmitter"
  74853. * @returns a string containing the class name
  74854. */
  74855. getClassName(): string;
  74856. /**
  74857. * Serializes the particle system to a JSON object.
  74858. * @returns the JSON object
  74859. */
  74860. serialize(): any;
  74861. /**
  74862. * Parse properties from a JSON object
  74863. * @param serializationObject defines the JSON object
  74864. */
  74865. parse(serializationObject: any): void;
  74866. }
  74867. }
  74868. declare module BABYLON {
  74869. /**
  74870. * Particle emitter emitting particles from the inside of a cylinder.
  74871. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  74872. */
  74873. export class CylinderParticleEmitter implements IParticleEmitterType {
  74874. /**
  74875. * The radius of the emission cylinder.
  74876. */
  74877. radius: number;
  74878. /**
  74879. * The height of the emission cylinder.
  74880. */
  74881. height: number;
  74882. /**
  74883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74884. */
  74885. radiusRange: number;
  74886. /**
  74887. * How much to randomize the particle direction [0-1].
  74888. */
  74889. directionRandomizer: number;
  74890. /**
  74891. * Creates a new instance CylinderParticleEmitter
  74892. * @param radius the radius of the emission cylinder (1 by default)
  74893. * @param height the height of the emission cylinder (1 by default)
  74894. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74895. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  74896. */
  74897. constructor(
  74898. /**
  74899. * The radius of the emission cylinder.
  74900. */
  74901. radius?: number,
  74902. /**
  74903. * The height of the emission cylinder.
  74904. */
  74905. height?: number,
  74906. /**
  74907. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  74908. */
  74909. radiusRange?: number,
  74910. /**
  74911. * How much to randomize the particle direction [0-1].
  74912. */
  74913. directionRandomizer?: number);
  74914. /**
  74915. * Called by the particle System when the direction is computed for the created particle.
  74916. * @param worldMatrix is the world matrix of the particle system
  74917. * @param directionToUpdate is the direction vector to update with the result
  74918. * @param particle is the particle we are computed the direction for
  74919. */
  74920. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74921. /**
  74922. * Called by the particle System when the position is computed for the created particle.
  74923. * @param worldMatrix is the world matrix of the particle system
  74924. * @param positionToUpdate is the position vector to update with the result
  74925. * @param particle is the particle we are computed the position for
  74926. */
  74927. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74928. /**
  74929. * Clones the current emitter and returns a copy of it
  74930. * @returns the new emitter
  74931. */
  74932. clone(): CylinderParticleEmitter;
  74933. /**
  74934. * Called by the GPUParticleSystem to setup the update shader
  74935. * @param effect defines the update shader
  74936. */
  74937. applyToShader(effect: Effect): void;
  74938. /**
  74939. * Returns a string to use to update the GPU particles update shader
  74940. * @returns a string containng the defines string
  74941. */
  74942. getEffectDefines(): string;
  74943. /**
  74944. * Returns the string "CylinderParticleEmitter"
  74945. * @returns a string containing the class name
  74946. */
  74947. getClassName(): string;
  74948. /**
  74949. * Serializes the particle system to a JSON object.
  74950. * @returns the JSON object
  74951. */
  74952. serialize(): any;
  74953. /**
  74954. * Parse properties from a JSON object
  74955. * @param serializationObject defines the JSON object
  74956. */
  74957. parse(serializationObject: any): void;
  74958. }
  74959. /**
  74960. * Particle emitter emitting particles from the inside of a cylinder.
  74961. * It emits the particles randomly between two vectors.
  74962. */
  74963. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  74964. /**
  74965. * The min limit of the emission direction.
  74966. */
  74967. direction1: Vector3;
  74968. /**
  74969. * The max limit of the emission direction.
  74970. */
  74971. direction2: Vector3;
  74972. /**
  74973. * Creates a new instance CylinderDirectedParticleEmitter
  74974. * @param radius the radius of the emission cylinder (1 by default)
  74975. * @param height the height of the emission cylinder (1 by default)
  74976. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74977. * @param direction1 the min limit of the emission direction (up vector by default)
  74978. * @param direction2 the max limit of the emission direction (up vector by default)
  74979. */
  74980. constructor(radius?: number, height?: number, radiusRange?: number,
  74981. /**
  74982. * The min limit of the emission direction.
  74983. */
  74984. direction1?: Vector3,
  74985. /**
  74986. * The max limit of the emission direction.
  74987. */
  74988. direction2?: Vector3);
  74989. /**
  74990. * Called by the particle System when the direction is computed for the created particle.
  74991. * @param worldMatrix is the world matrix of the particle system
  74992. * @param directionToUpdate is the direction vector to update with the result
  74993. * @param particle is the particle we are computed the direction for
  74994. */
  74995. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74996. /**
  74997. * Clones the current emitter and returns a copy of it
  74998. * @returns the new emitter
  74999. */
  75000. clone(): CylinderDirectedParticleEmitter;
  75001. /**
  75002. * Called by the GPUParticleSystem to setup the update shader
  75003. * @param effect defines the update shader
  75004. */
  75005. applyToShader(effect: Effect): void;
  75006. /**
  75007. * Returns a string to use to update the GPU particles update shader
  75008. * @returns a string containng the defines string
  75009. */
  75010. getEffectDefines(): string;
  75011. /**
  75012. * Returns the string "CylinderDirectedParticleEmitter"
  75013. * @returns a string containing the class name
  75014. */
  75015. getClassName(): string;
  75016. /**
  75017. * Serializes the particle system to a JSON object.
  75018. * @returns the JSON object
  75019. */
  75020. serialize(): any;
  75021. /**
  75022. * Parse properties from a JSON object
  75023. * @param serializationObject defines the JSON object
  75024. */
  75025. parse(serializationObject: any): void;
  75026. }
  75027. }
  75028. declare module BABYLON {
  75029. /**
  75030. * Particle emitter emitting particles from the inside of a hemisphere.
  75031. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75032. */
  75033. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75034. /**
  75035. * The radius of the emission hemisphere.
  75036. */
  75037. radius: number;
  75038. /**
  75039. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75040. */
  75041. radiusRange: number;
  75042. /**
  75043. * How much to randomize the particle direction [0-1].
  75044. */
  75045. directionRandomizer: number;
  75046. /**
  75047. * Creates a new instance HemisphericParticleEmitter
  75048. * @param radius the radius of the emission hemisphere (1 by default)
  75049. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75050. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75051. */
  75052. constructor(
  75053. /**
  75054. * The radius of the emission hemisphere.
  75055. */
  75056. radius?: number,
  75057. /**
  75058. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75059. */
  75060. radiusRange?: number,
  75061. /**
  75062. * How much to randomize the particle direction [0-1].
  75063. */
  75064. directionRandomizer?: number);
  75065. /**
  75066. * Called by the particle System when the direction is computed for the created particle.
  75067. * @param worldMatrix is the world matrix of the particle system
  75068. * @param directionToUpdate is the direction vector to update with the result
  75069. * @param particle is the particle we are computed the direction for
  75070. */
  75071. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75072. /**
  75073. * Called by the particle System when the position is computed for the created particle.
  75074. * @param worldMatrix is the world matrix of the particle system
  75075. * @param positionToUpdate is the position vector to update with the result
  75076. * @param particle is the particle we are computed the position for
  75077. */
  75078. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75079. /**
  75080. * Clones the current emitter and returns a copy of it
  75081. * @returns the new emitter
  75082. */
  75083. clone(): HemisphericParticleEmitter;
  75084. /**
  75085. * Called by the GPUParticleSystem to setup the update shader
  75086. * @param effect defines the update shader
  75087. */
  75088. applyToShader(effect: Effect): void;
  75089. /**
  75090. * Returns a string to use to update the GPU particles update shader
  75091. * @returns a string containng the defines string
  75092. */
  75093. getEffectDefines(): string;
  75094. /**
  75095. * Returns the string "HemisphericParticleEmitter"
  75096. * @returns a string containing the class name
  75097. */
  75098. getClassName(): string;
  75099. /**
  75100. * Serializes the particle system to a JSON object.
  75101. * @returns the JSON object
  75102. */
  75103. serialize(): any;
  75104. /**
  75105. * Parse properties from a JSON object
  75106. * @param serializationObject defines the JSON object
  75107. */
  75108. parse(serializationObject: any): void;
  75109. }
  75110. }
  75111. declare module BABYLON {
  75112. /**
  75113. * Particle emitter emitting particles from a point.
  75114. * It emits the particles randomly between 2 given directions.
  75115. */
  75116. export class PointParticleEmitter implements IParticleEmitterType {
  75117. /**
  75118. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75119. */
  75120. direction1: Vector3;
  75121. /**
  75122. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75123. */
  75124. direction2: Vector3;
  75125. /**
  75126. * Creates a new instance PointParticleEmitter
  75127. */
  75128. constructor();
  75129. /**
  75130. * Called by the particle System when the direction is computed for the created particle.
  75131. * @param worldMatrix is the world matrix of the particle system
  75132. * @param directionToUpdate is the direction vector to update with the result
  75133. * @param particle is the particle we are computed the direction for
  75134. */
  75135. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75136. /**
  75137. * Called by the particle System when the position is computed for the created particle.
  75138. * @param worldMatrix is the world matrix of the particle system
  75139. * @param positionToUpdate is the position vector to update with the result
  75140. * @param particle is the particle we are computed the position for
  75141. */
  75142. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75143. /**
  75144. * Clones the current emitter and returns a copy of it
  75145. * @returns the new emitter
  75146. */
  75147. clone(): PointParticleEmitter;
  75148. /**
  75149. * Called by the GPUParticleSystem to setup the update shader
  75150. * @param effect defines the update shader
  75151. */
  75152. applyToShader(effect: Effect): void;
  75153. /**
  75154. * Returns a string to use to update the GPU particles update shader
  75155. * @returns a string containng the defines string
  75156. */
  75157. getEffectDefines(): string;
  75158. /**
  75159. * Returns the string "PointParticleEmitter"
  75160. * @returns a string containing the class name
  75161. */
  75162. getClassName(): string;
  75163. /**
  75164. * Serializes the particle system to a JSON object.
  75165. * @returns the JSON object
  75166. */
  75167. serialize(): any;
  75168. /**
  75169. * Parse properties from a JSON object
  75170. * @param serializationObject defines the JSON object
  75171. */
  75172. parse(serializationObject: any): void;
  75173. }
  75174. }
  75175. declare module BABYLON {
  75176. /**
  75177. * Particle emitter emitting particles from the inside of a sphere.
  75178. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75179. */
  75180. export class SphereParticleEmitter implements IParticleEmitterType {
  75181. /**
  75182. * The radius of the emission sphere.
  75183. */
  75184. radius: number;
  75185. /**
  75186. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75187. */
  75188. radiusRange: number;
  75189. /**
  75190. * How much to randomize the particle direction [0-1].
  75191. */
  75192. directionRandomizer: number;
  75193. /**
  75194. * Creates a new instance SphereParticleEmitter
  75195. * @param radius the radius of the emission sphere (1 by default)
  75196. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75197. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75198. */
  75199. constructor(
  75200. /**
  75201. * The radius of the emission sphere.
  75202. */
  75203. radius?: number,
  75204. /**
  75205. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75206. */
  75207. radiusRange?: number,
  75208. /**
  75209. * How much to randomize the particle direction [0-1].
  75210. */
  75211. directionRandomizer?: number);
  75212. /**
  75213. * Called by the particle System when the direction is computed for the created particle.
  75214. * @param worldMatrix is the world matrix of the particle system
  75215. * @param directionToUpdate is the direction vector to update with the result
  75216. * @param particle is the particle we are computed the direction for
  75217. */
  75218. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75219. /**
  75220. * Called by the particle System when the position is computed for the created particle.
  75221. * @param worldMatrix is the world matrix of the particle system
  75222. * @param positionToUpdate is the position vector to update with the result
  75223. * @param particle is the particle we are computed the position for
  75224. */
  75225. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75226. /**
  75227. * Clones the current emitter and returns a copy of it
  75228. * @returns the new emitter
  75229. */
  75230. clone(): SphereParticleEmitter;
  75231. /**
  75232. * Called by the GPUParticleSystem to setup the update shader
  75233. * @param effect defines the update shader
  75234. */
  75235. applyToShader(effect: Effect): void;
  75236. /**
  75237. * Returns a string to use to update the GPU particles update shader
  75238. * @returns a string containng the defines string
  75239. */
  75240. getEffectDefines(): string;
  75241. /**
  75242. * Returns the string "SphereParticleEmitter"
  75243. * @returns a string containing the class name
  75244. */
  75245. getClassName(): string;
  75246. /**
  75247. * Serializes the particle system to a JSON object.
  75248. * @returns the JSON object
  75249. */
  75250. serialize(): any;
  75251. /**
  75252. * Parse properties from a JSON object
  75253. * @param serializationObject defines the JSON object
  75254. */
  75255. parse(serializationObject: any): void;
  75256. }
  75257. /**
  75258. * Particle emitter emitting particles from the inside of a sphere.
  75259. * It emits the particles randomly between two vectors.
  75260. */
  75261. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75262. /**
  75263. * The min limit of the emission direction.
  75264. */
  75265. direction1: Vector3;
  75266. /**
  75267. * The max limit of the emission direction.
  75268. */
  75269. direction2: Vector3;
  75270. /**
  75271. * Creates a new instance SphereDirectedParticleEmitter
  75272. * @param radius the radius of the emission sphere (1 by default)
  75273. * @param direction1 the min limit of the emission direction (up vector by default)
  75274. * @param direction2 the max limit of the emission direction (up vector by default)
  75275. */
  75276. constructor(radius?: number,
  75277. /**
  75278. * The min limit of the emission direction.
  75279. */
  75280. direction1?: Vector3,
  75281. /**
  75282. * The max limit of the emission direction.
  75283. */
  75284. direction2?: Vector3);
  75285. /**
  75286. * Called by the particle System when the direction is computed for the created particle.
  75287. * @param worldMatrix is the world matrix of the particle system
  75288. * @param directionToUpdate is the direction vector to update with the result
  75289. * @param particle is the particle we are computed the direction for
  75290. */
  75291. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75292. /**
  75293. * Clones the current emitter and returns a copy of it
  75294. * @returns the new emitter
  75295. */
  75296. clone(): SphereDirectedParticleEmitter;
  75297. /**
  75298. * Called by the GPUParticleSystem to setup the update shader
  75299. * @param effect defines the update shader
  75300. */
  75301. applyToShader(effect: Effect): void;
  75302. /**
  75303. * Returns a string to use to update the GPU particles update shader
  75304. * @returns a string containng the defines string
  75305. */
  75306. getEffectDefines(): string;
  75307. /**
  75308. * Returns the string "SphereDirectedParticleEmitter"
  75309. * @returns a string containing the class name
  75310. */
  75311. getClassName(): string;
  75312. /**
  75313. * Serializes the particle system to a JSON object.
  75314. * @returns the JSON object
  75315. */
  75316. serialize(): any;
  75317. /**
  75318. * Parse properties from a JSON object
  75319. * @param serializationObject defines the JSON object
  75320. */
  75321. parse(serializationObject: any): void;
  75322. }
  75323. }
  75324. declare module BABYLON {
  75325. /**
  75326. * Interface representing a particle system in Babylon.js.
  75327. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75328. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75329. */
  75330. export interface IParticleSystem {
  75331. /**
  75332. * List of animations used by the particle system.
  75333. */
  75334. animations: Animation[];
  75335. /**
  75336. * The id of the Particle system.
  75337. */
  75338. id: string;
  75339. /**
  75340. * The name of the Particle system.
  75341. */
  75342. name: string;
  75343. /**
  75344. * The emitter represents the Mesh or position we are attaching the particle system to.
  75345. */
  75346. emitter: Nullable<AbstractMesh | Vector3>;
  75347. /**
  75348. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75349. */
  75350. isBillboardBased: boolean;
  75351. /**
  75352. * The rendering group used by the Particle system to chose when to render.
  75353. */
  75354. renderingGroupId: number;
  75355. /**
  75356. * The layer mask we are rendering the particles through.
  75357. */
  75358. layerMask: number;
  75359. /**
  75360. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75361. */
  75362. updateSpeed: number;
  75363. /**
  75364. * The amount of time the particle system is running (depends of the overall update speed).
  75365. */
  75366. targetStopDuration: number;
  75367. /**
  75368. * The texture used to render each particle. (this can be a spritesheet)
  75369. */
  75370. particleTexture: Nullable<Texture>;
  75371. /**
  75372. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75373. */
  75374. blendMode: number;
  75375. /**
  75376. * Minimum life time of emitting particles.
  75377. */
  75378. minLifeTime: number;
  75379. /**
  75380. * Maximum life time of emitting particles.
  75381. */
  75382. maxLifeTime: number;
  75383. /**
  75384. * Minimum Size of emitting particles.
  75385. */
  75386. minSize: number;
  75387. /**
  75388. * Maximum Size of emitting particles.
  75389. */
  75390. maxSize: number;
  75391. /**
  75392. * Minimum scale of emitting particles on X axis.
  75393. */
  75394. minScaleX: number;
  75395. /**
  75396. * Maximum scale of emitting particles on X axis.
  75397. */
  75398. maxScaleX: number;
  75399. /**
  75400. * Minimum scale of emitting particles on Y axis.
  75401. */
  75402. minScaleY: number;
  75403. /**
  75404. * Maximum scale of emitting particles on Y axis.
  75405. */
  75406. maxScaleY: number;
  75407. /**
  75408. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75409. */
  75410. color1: Color4;
  75411. /**
  75412. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75413. */
  75414. color2: Color4;
  75415. /**
  75416. * Color the particle will have at the end of its lifetime.
  75417. */
  75418. colorDead: Color4;
  75419. /**
  75420. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75421. */
  75422. emitRate: number;
  75423. /**
  75424. * You can use gravity if you want to give an orientation to your particles.
  75425. */
  75426. gravity: Vector3;
  75427. /**
  75428. * Minimum power of emitting particles.
  75429. */
  75430. minEmitPower: number;
  75431. /**
  75432. * Maximum power of emitting particles.
  75433. */
  75434. maxEmitPower: number;
  75435. /**
  75436. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75437. */
  75438. minAngularSpeed: number;
  75439. /**
  75440. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75441. */
  75442. maxAngularSpeed: number;
  75443. /**
  75444. * Gets or sets the minimal initial rotation in radians.
  75445. */
  75446. minInitialRotation: number;
  75447. /**
  75448. * Gets or sets the maximal initial rotation in radians.
  75449. */
  75450. maxInitialRotation: number;
  75451. /**
  75452. * The particle emitter type defines the emitter used by the particle system.
  75453. * It can be for example box, sphere, or cone...
  75454. */
  75455. particleEmitterType: Nullable<IParticleEmitterType>;
  75456. /**
  75457. * Defines the delay in milliseconds before starting the system (0 by default)
  75458. */
  75459. startDelay: number;
  75460. /**
  75461. * 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
  75462. */
  75463. preWarmCycles: number;
  75464. /**
  75465. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75466. */
  75467. preWarmStepOffset: number;
  75468. /**
  75469. * 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)
  75470. */
  75471. spriteCellChangeSpeed: number;
  75472. /**
  75473. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75474. */
  75475. startSpriteCellID: number;
  75476. /**
  75477. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75478. */
  75479. endSpriteCellID: number;
  75480. /**
  75481. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75482. */
  75483. spriteCellWidth: number;
  75484. /**
  75485. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75486. */
  75487. spriteCellHeight: number;
  75488. /**
  75489. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75490. */
  75491. spriteRandomStartCell: boolean;
  75492. /**
  75493. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75494. */
  75495. isAnimationSheetEnabled: boolean;
  75496. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75497. translationPivot: Vector2;
  75498. /**
  75499. * Gets or sets a texture used to add random noise to particle positions
  75500. */
  75501. noiseTexture: Nullable<BaseTexture>;
  75502. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75503. noiseStrength: Vector3;
  75504. /**
  75505. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75506. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75507. */
  75508. billboardMode: number;
  75509. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75510. limitVelocityDamping: number;
  75511. /**
  75512. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75513. */
  75514. beginAnimationOnStart: boolean;
  75515. /**
  75516. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75517. */
  75518. beginAnimationFrom: number;
  75519. /**
  75520. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75521. */
  75522. beginAnimationTo: number;
  75523. /**
  75524. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75525. */
  75526. beginAnimationLoop: boolean;
  75527. /**
  75528. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75529. */
  75530. disposeOnStop: boolean;
  75531. /**
  75532. * Gets the maximum number of particles active at the same time.
  75533. * @returns The max number of active particles.
  75534. */
  75535. getCapacity(): number;
  75536. /**
  75537. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75538. * @returns True if it has been started, otherwise false.
  75539. */
  75540. isStarted(): boolean;
  75541. /**
  75542. * Animates the particle system for this frame.
  75543. */
  75544. animate(): void;
  75545. /**
  75546. * Renders the particle system in its current state.
  75547. * @returns the current number of particles
  75548. */
  75549. render(): number;
  75550. /**
  75551. * Dispose the particle system and frees its associated resources.
  75552. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75553. */
  75554. dispose(disposeTexture?: boolean): void;
  75555. /**
  75556. * Clones the particle system.
  75557. * @param name The name of the cloned object
  75558. * @param newEmitter The new emitter to use
  75559. * @returns the cloned particle system
  75560. */
  75561. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75562. /**
  75563. * Serializes the particle system to a JSON object.
  75564. * @returns the JSON object
  75565. */
  75566. serialize(): any;
  75567. /**
  75568. * Rebuild the particle system
  75569. */
  75570. rebuild(): void;
  75571. /**
  75572. * Starts the particle system and begins to emit
  75573. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75574. */
  75575. start(delay?: number): void;
  75576. /**
  75577. * Stops the particle system.
  75578. */
  75579. stop(): void;
  75580. /**
  75581. * Remove all active particles
  75582. */
  75583. reset(): void;
  75584. /**
  75585. * Is this system ready to be used/rendered
  75586. * @return true if the system is ready
  75587. */
  75588. isReady(): boolean;
  75589. /**
  75590. * Adds a new color gradient
  75591. * @param gradient defines the gradient to use (between 0 and 1)
  75592. * @param color1 defines the color to affect to the specified gradient
  75593. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75594. * @returns the current particle system
  75595. */
  75596. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75597. /**
  75598. * Remove a specific color gradient
  75599. * @param gradient defines the gradient to remove
  75600. * @returns the current particle system
  75601. */
  75602. removeColorGradient(gradient: number): IParticleSystem;
  75603. /**
  75604. * Adds a new size gradient
  75605. * @param gradient defines the gradient to use (between 0 and 1)
  75606. * @param factor defines the size factor to affect to the specified gradient
  75607. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75608. * @returns the current particle system
  75609. */
  75610. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75611. /**
  75612. * Remove a specific size gradient
  75613. * @param gradient defines the gradient to remove
  75614. * @returns the current particle system
  75615. */
  75616. removeSizeGradient(gradient: number): IParticleSystem;
  75617. /**
  75618. * Gets the current list of color gradients.
  75619. * You must use addColorGradient and removeColorGradient to udpate this list
  75620. * @returns the list of color gradients
  75621. */
  75622. getColorGradients(): Nullable<Array<ColorGradient>>;
  75623. /**
  75624. * Gets the current list of size gradients.
  75625. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75626. * @returns the list of size gradients
  75627. */
  75628. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75629. /**
  75630. * Gets the current list of angular speed gradients.
  75631. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75632. * @returns the list of angular speed gradients
  75633. */
  75634. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75635. /**
  75636. * Adds a new angular speed gradient
  75637. * @param gradient defines the gradient to use (between 0 and 1)
  75638. * @param factor defines the angular speed to affect to the specified gradient
  75639. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75640. * @returns the current particle system
  75641. */
  75642. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75643. /**
  75644. * Remove a specific angular speed gradient
  75645. * @param gradient defines the gradient to remove
  75646. * @returns the current particle system
  75647. */
  75648. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75649. /**
  75650. * Gets the current list of velocity gradients.
  75651. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75652. * @returns the list of velocity gradients
  75653. */
  75654. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75655. /**
  75656. * Adds a new velocity gradient
  75657. * @param gradient defines the gradient to use (between 0 and 1)
  75658. * @param factor defines the velocity to affect to the specified gradient
  75659. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75660. * @returns the current particle system
  75661. */
  75662. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75663. /**
  75664. * Remove a specific velocity gradient
  75665. * @param gradient defines the gradient to remove
  75666. * @returns the current particle system
  75667. */
  75668. removeVelocityGradient(gradient: number): IParticleSystem;
  75669. /**
  75670. * Gets the current list of limit velocity gradients.
  75671. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75672. * @returns the list of limit velocity gradients
  75673. */
  75674. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75675. /**
  75676. * Adds a new limit velocity gradient
  75677. * @param gradient defines the gradient to use (between 0 and 1)
  75678. * @param factor defines the limit velocity to affect to the specified gradient
  75679. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75680. * @returns the current particle system
  75681. */
  75682. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75683. /**
  75684. * Remove a specific limit velocity gradient
  75685. * @param gradient defines the gradient to remove
  75686. * @returns the current particle system
  75687. */
  75688. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75689. /**
  75690. * Adds a new drag gradient
  75691. * @param gradient defines the gradient to use (between 0 and 1)
  75692. * @param factor defines the drag to affect to the specified gradient
  75693. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75694. * @returns the current particle system
  75695. */
  75696. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75697. /**
  75698. * Remove a specific drag gradient
  75699. * @param gradient defines the gradient to remove
  75700. * @returns the current particle system
  75701. */
  75702. removeDragGradient(gradient: number): IParticleSystem;
  75703. /**
  75704. * Gets the current list of drag gradients.
  75705. * You must use addDragGradient and removeDragGradient to udpate this list
  75706. * @returns the list of drag gradients
  75707. */
  75708. getDragGradients(): Nullable<Array<FactorGradient>>;
  75709. /**
  75710. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75711. * @param gradient defines the gradient to use (between 0 and 1)
  75712. * @param factor defines the emit rate to affect to the specified gradient
  75713. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75714. * @returns the current particle system
  75715. */
  75716. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75717. /**
  75718. * Remove a specific emit rate gradient
  75719. * @param gradient defines the gradient to remove
  75720. * @returns the current particle system
  75721. */
  75722. removeEmitRateGradient(gradient: number): IParticleSystem;
  75723. /**
  75724. * Gets the current list of emit rate gradients.
  75725. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75726. * @returns the list of emit rate gradients
  75727. */
  75728. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75729. /**
  75730. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75731. * @param gradient defines the gradient to use (between 0 and 1)
  75732. * @param factor defines the start size to affect to the specified gradient
  75733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75734. * @returns the current particle system
  75735. */
  75736. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75737. /**
  75738. * Remove a specific start size gradient
  75739. * @param gradient defines the gradient to remove
  75740. * @returns the current particle system
  75741. */
  75742. removeStartSizeGradient(gradient: number): IParticleSystem;
  75743. /**
  75744. * Gets the current list of start size gradients.
  75745. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75746. * @returns the list of start size gradients
  75747. */
  75748. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75749. /**
  75750. * Adds a new life time gradient
  75751. * @param gradient defines the gradient to use (between 0 and 1)
  75752. * @param factor defines the life time factor to affect to the specified gradient
  75753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75754. * @returns the current particle system
  75755. */
  75756. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75757. /**
  75758. * Remove a specific life time gradient
  75759. * @param gradient defines the gradient to remove
  75760. * @returns the current particle system
  75761. */
  75762. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75763. /**
  75764. * Gets the current list of life time gradients.
  75765. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75766. * @returns the list of life time gradients
  75767. */
  75768. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75769. /**
  75770. * Gets the current list of color gradients.
  75771. * You must use addColorGradient and removeColorGradient to udpate this list
  75772. * @returns the list of color gradients
  75773. */
  75774. getColorGradients(): Nullable<Array<ColorGradient>>;
  75775. /**
  75776. * Adds a new ramp gradient used to remap particle colors
  75777. * @param gradient defines the gradient to use (between 0 and 1)
  75778. * @param color defines the color to affect to the specified gradient
  75779. * @returns the current particle system
  75780. */
  75781. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75782. /**
  75783. * Gets the current list of ramp gradients.
  75784. * You must use addRampGradient and removeRampGradient to udpate this list
  75785. * @returns the list of ramp gradients
  75786. */
  75787. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75788. /** Gets or sets a boolean indicating that ramp gradients must be used
  75789. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75790. */
  75791. useRampGradients: boolean;
  75792. /**
  75793. * Adds a new color remap gradient
  75794. * @param gradient defines the gradient to use (between 0 and 1)
  75795. * @param min defines the color remap minimal range
  75796. * @param max defines the color remap maximal range
  75797. * @returns the current particle system
  75798. */
  75799. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75800. /**
  75801. * Gets the current list of color remap gradients.
  75802. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75803. * @returns the list of color remap gradients
  75804. */
  75805. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75806. /**
  75807. * Adds a new alpha remap gradient
  75808. * @param gradient defines the gradient to use (between 0 and 1)
  75809. * @param min defines the alpha remap minimal range
  75810. * @param max defines the alpha remap maximal range
  75811. * @returns the current particle system
  75812. */
  75813. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75814. /**
  75815. * Gets the current list of alpha remap gradients.
  75816. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75817. * @returns the list of alpha remap gradients
  75818. */
  75819. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75820. /**
  75821. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75822. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75823. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75824. * @returns the emitter
  75825. */
  75826. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75827. /**
  75828. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75829. * @param radius The radius of the hemisphere to emit from
  75830. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75831. * @returns the emitter
  75832. */
  75833. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75834. /**
  75835. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75836. * @param radius The radius of the sphere to emit from
  75837. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75838. * @returns the emitter
  75839. */
  75840. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75841. /**
  75842. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75843. * @param radius The radius of the sphere to emit from
  75844. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75845. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75846. * @returns the emitter
  75847. */
  75848. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75849. /**
  75850. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75851. * @param radius The radius of the emission cylinder
  75852. * @param height The height of the emission cylinder
  75853. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75854. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75855. * @returns the emitter
  75856. */
  75857. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75858. /**
  75859. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  75860. * @param radius The radius of the cylinder to emit from
  75861. * @param height The height of the emission cylinder
  75862. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75863. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  75864. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  75865. * @returns the emitter
  75866. */
  75867. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75868. /**
  75869. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  75870. * @param radius The radius of the cone to emit from
  75871. * @param angle The base angle of the cone
  75872. * @returns the emitter
  75873. */
  75874. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  75875. /**
  75876. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  75877. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75878. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75879. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75880. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  75881. * @returns the emitter
  75882. */
  75883. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  75884. /**
  75885. * Get hosting scene
  75886. * @returns the scene
  75887. */
  75888. getScene(): Scene;
  75889. }
  75890. }
  75891. declare module BABYLON {
  75892. /**
  75893. * Creates an instance based on a source mesh.
  75894. */
  75895. export class InstancedMesh extends AbstractMesh {
  75896. private _sourceMesh;
  75897. private _currentLOD;
  75898. /** @hidden */
  75899. _indexInSourceMeshInstanceArray: number;
  75900. constructor(name: string, source: Mesh);
  75901. /**
  75902. * Returns the string "InstancedMesh".
  75903. */
  75904. getClassName(): string;
  75905. /**
  75906. * If the source mesh receives shadows
  75907. */
  75908. readonly receiveShadows: boolean;
  75909. /**
  75910. * The material of the source mesh
  75911. */
  75912. readonly material: Nullable<Material>;
  75913. /**
  75914. * Visibility of the source mesh
  75915. */
  75916. readonly visibility: number;
  75917. /**
  75918. * Skeleton of the source mesh
  75919. */
  75920. readonly skeleton: Nullable<Skeleton>;
  75921. /**
  75922. * Rendering ground id of the source mesh
  75923. */
  75924. renderingGroupId: number;
  75925. /**
  75926. * Returns the total number of vertices (integer).
  75927. */
  75928. getTotalVertices(): number;
  75929. /**
  75930. * Returns a positive integer : the total number of indices in this mesh geometry.
  75931. * @returns the numner of indices or zero if the mesh has no geometry.
  75932. */
  75933. getTotalIndices(): number;
  75934. /**
  75935. * The source mesh of the instance
  75936. */
  75937. readonly sourceMesh: Mesh;
  75938. /**
  75939. * Is this node ready to be used/rendered
  75940. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  75941. * @return {boolean} is it ready
  75942. */
  75943. isReady(completeCheck?: boolean): boolean;
  75944. /**
  75945. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  75946. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  75947. * @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.
  75948. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  75949. */
  75950. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  75951. /**
  75952. * Sets the vertex data of the mesh geometry for the requested `kind`.
  75953. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  75954. * The `data` are either a numeric array either a Float32Array.
  75955. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  75956. * 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).
  75957. * Note that a new underlying VertexBuffer object is created each call.
  75958. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  75959. *
  75960. * Possible `kind` values :
  75961. * - VertexBuffer.PositionKind
  75962. * - VertexBuffer.UVKind
  75963. * - VertexBuffer.UV2Kind
  75964. * - VertexBuffer.UV3Kind
  75965. * - VertexBuffer.UV4Kind
  75966. * - VertexBuffer.UV5Kind
  75967. * - VertexBuffer.UV6Kind
  75968. * - VertexBuffer.ColorKind
  75969. * - VertexBuffer.MatricesIndicesKind
  75970. * - VertexBuffer.MatricesIndicesExtraKind
  75971. * - VertexBuffer.MatricesWeightsKind
  75972. * - VertexBuffer.MatricesWeightsExtraKind
  75973. *
  75974. * Returns the Mesh.
  75975. */
  75976. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  75977. /**
  75978. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  75979. * If the mesh has no geometry, it is simply returned as it is.
  75980. * The `data` are either a numeric array either a Float32Array.
  75981. * No new underlying VertexBuffer object is created.
  75982. * 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.
  75983. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  75984. *
  75985. * Possible `kind` values :
  75986. * - VertexBuffer.PositionKind
  75987. * - VertexBuffer.UVKind
  75988. * - VertexBuffer.UV2Kind
  75989. * - VertexBuffer.UV3Kind
  75990. * - VertexBuffer.UV4Kind
  75991. * - VertexBuffer.UV5Kind
  75992. * - VertexBuffer.UV6Kind
  75993. * - VertexBuffer.ColorKind
  75994. * - VertexBuffer.MatricesIndicesKind
  75995. * - VertexBuffer.MatricesIndicesExtraKind
  75996. * - VertexBuffer.MatricesWeightsKind
  75997. * - VertexBuffer.MatricesWeightsExtraKind
  75998. *
  75999. * Returns the Mesh.
  76000. */
  76001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76002. /**
  76003. * Sets the mesh indices.
  76004. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76005. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76006. * This method creates a new index buffer each call.
  76007. * Returns the Mesh.
  76008. */
  76009. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76010. /**
  76011. * Boolean : True if the mesh owns the requested kind of data.
  76012. */
  76013. isVerticesDataPresent(kind: string): boolean;
  76014. /**
  76015. * Returns an array of indices (IndicesArray).
  76016. */
  76017. getIndices(): Nullable<IndicesArray>;
  76018. readonly _positions: Nullable<Vector3[]>;
  76019. /**
  76020. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76021. * This means the mesh underlying bounding box and sphere are recomputed.
  76022. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76023. * @returns the current mesh
  76024. */
  76025. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76026. /** @hidden */
  76027. _preActivate(): InstancedMesh;
  76028. /** @hidden */
  76029. _activate(renderId: number): boolean;
  76030. /**
  76031. * Returns the current associated LOD AbstractMesh.
  76032. */
  76033. getLOD(camera: Camera): AbstractMesh;
  76034. /** @hidden */
  76035. _syncSubMeshes(): InstancedMesh;
  76036. /** @hidden */
  76037. _generatePointsArray(): boolean;
  76038. /**
  76039. * Creates a new InstancedMesh from the current mesh.
  76040. * - name (string) : the cloned mesh name
  76041. * - newParent (optional Node) : the optional Node to parent the clone to.
  76042. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76043. *
  76044. * Returns the clone.
  76045. */
  76046. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76047. /**
  76048. * Disposes the InstancedMesh.
  76049. * Returns nothing.
  76050. */
  76051. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76052. }
  76053. }
  76054. declare module BABYLON {
  76055. /**
  76056. * Defines the options associated with the creation of a shader material.
  76057. */
  76058. export interface IShaderMaterialOptions {
  76059. /**
  76060. * Does the material work in alpha blend mode
  76061. */
  76062. needAlphaBlending: boolean;
  76063. /**
  76064. * Does the material work in alpha test mode
  76065. */
  76066. needAlphaTesting: boolean;
  76067. /**
  76068. * The list of attribute names used in the shader
  76069. */
  76070. attributes: string[];
  76071. /**
  76072. * The list of unifrom names used in the shader
  76073. */
  76074. uniforms: string[];
  76075. /**
  76076. * The list of UBO names used in the shader
  76077. */
  76078. uniformBuffers: string[];
  76079. /**
  76080. * The list of sampler names used in the shader
  76081. */
  76082. samplers: string[];
  76083. /**
  76084. * The list of defines used in the shader
  76085. */
  76086. defines: string[];
  76087. }
  76088. /**
  76089. * 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.
  76090. *
  76091. * This returned material effects how the mesh will look based on the code in the shaders.
  76092. *
  76093. * @see http://doc.babylonjs.com/how_to/shader_material
  76094. */
  76095. export class ShaderMaterial extends Material {
  76096. private _shaderPath;
  76097. private _options;
  76098. private _textures;
  76099. private _textureArrays;
  76100. private _floats;
  76101. private _ints;
  76102. private _floatsArrays;
  76103. private _colors3;
  76104. private _colors3Arrays;
  76105. private _colors4;
  76106. private _vectors2;
  76107. private _vectors3;
  76108. private _vectors4;
  76109. private _matrices;
  76110. private _matrices3x3;
  76111. private _matrices2x2;
  76112. private _vectors2Arrays;
  76113. private _vectors3Arrays;
  76114. private _cachedWorldViewMatrix;
  76115. private _renderId;
  76116. /**
  76117. * Instantiate a new shader material.
  76118. * 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.
  76119. * This returned material effects how the mesh will look based on the code in the shaders.
  76120. * @see http://doc.babylonjs.com/how_to/shader_material
  76121. * @param name Define the name of the material in the scene
  76122. * @param scene Define the scene the material belongs to
  76123. * @param shaderPath Defines the route to the shader code in one of three ways:
  76124. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76125. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76126. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76127. * @param options Define the options used to create the shader
  76128. */
  76129. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76130. /**
  76131. * Gets the options used to compile the shader.
  76132. * They can be modified to trigger a new compilation
  76133. */
  76134. readonly options: IShaderMaterialOptions;
  76135. /**
  76136. * Gets the current class name of the material e.g. "ShaderMaterial"
  76137. * Mainly use in serialization.
  76138. * @returns the class name
  76139. */
  76140. getClassName(): string;
  76141. /**
  76142. * Specifies if the material will require alpha blending
  76143. * @returns a boolean specifying if alpha blending is needed
  76144. */
  76145. needAlphaBlending(): boolean;
  76146. /**
  76147. * Specifies if this material should be rendered in alpha test mode
  76148. * @returns a boolean specifying if an alpha test is needed.
  76149. */
  76150. needAlphaTesting(): boolean;
  76151. private _checkUniform;
  76152. /**
  76153. * Set a texture in the shader.
  76154. * @param name Define the name of the uniform samplers as defined in the shader
  76155. * @param texture Define the texture to bind to this sampler
  76156. * @return the material itself allowing "fluent" like uniform updates
  76157. */
  76158. setTexture(name: string, texture: Texture): ShaderMaterial;
  76159. /**
  76160. * Set a texture array in the shader.
  76161. * @param name Define the name of the uniform sampler array as defined in the shader
  76162. * @param textures Define the list of textures to bind to this sampler
  76163. * @return the material itself allowing "fluent" like uniform updates
  76164. */
  76165. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76166. /**
  76167. * Set a float in the shader.
  76168. * @param name Define the name of the uniform as defined in the shader
  76169. * @param value Define the value to give to the uniform
  76170. * @return the material itself allowing "fluent" like uniform updates
  76171. */
  76172. setFloat(name: string, value: number): ShaderMaterial;
  76173. /**
  76174. * Set a int in the shader.
  76175. * @param name Define the name of the uniform as defined in the shader
  76176. * @param value Define the value to give to the uniform
  76177. * @return the material itself allowing "fluent" like uniform updates
  76178. */
  76179. setInt(name: string, value: number): ShaderMaterial;
  76180. /**
  76181. * Set an array of floats in the shader.
  76182. * @param name Define the name of the uniform as defined in the shader
  76183. * @param value Define the value to give to the uniform
  76184. * @return the material itself allowing "fluent" like uniform updates
  76185. */
  76186. setFloats(name: string, value: number[]): ShaderMaterial;
  76187. /**
  76188. * Set a vec3 in the shader from a Color3.
  76189. * @param name Define the name of the uniform as defined in the shader
  76190. * @param value Define the value to give to the uniform
  76191. * @return the material itself allowing "fluent" like uniform updates
  76192. */
  76193. setColor3(name: string, value: Color3): ShaderMaterial;
  76194. /**
  76195. * Set a vec3 array in the shader from a Color3 array.
  76196. * @param name Define the name of the uniform as defined in the shader
  76197. * @param value Define the value to give to the uniform
  76198. * @return the material itself allowing "fluent" like uniform updates
  76199. */
  76200. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76201. /**
  76202. * Set a vec4 in the shader from a Color4.
  76203. * @param name Define the name of the uniform as defined in the shader
  76204. * @param value Define the value to give to the uniform
  76205. * @return the material itself allowing "fluent" like uniform updates
  76206. */
  76207. setColor4(name: string, value: Color4): ShaderMaterial;
  76208. /**
  76209. * Set a vec2 in the shader from a Vector2.
  76210. * @param name Define the name of the uniform as defined in the shader
  76211. * @param value Define the value to give to the uniform
  76212. * @return the material itself allowing "fluent" like uniform updates
  76213. */
  76214. setVector2(name: string, value: Vector2): ShaderMaterial;
  76215. /**
  76216. * Set a vec3 in the shader from a Vector3.
  76217. * @param name Define the name of the uniform as defined in the shader
  76218. * @param value Define the value to give to the uniform
  76219. * @return the material itself allowing "fluent" like uniform updates
  76220. */
  76221. setVector3(name: string, value: Vector3): ShaderMaterial;
  76222. /**
  76223. * Set a vec4 in the shader from a Vector4.
  76224. * @param name Define the name of the uniform as defined in the shader
  76225. * @param value Define the value to give to the uniform
  76226. * @return the material itself allowing "fluent" like uniform updates
  76227. */
  76228. setVector4(name: string, value: Vector4): ShaderMaterial;
  76229. /**
  76230. * Set a mat4 in the shader from a Matrix.
  76231. * @param name Define the name of the uniform as defined in the shader
  76232. * @param value Define the value to give to the uniform
  76233. * @return the material itself allowing "fluent" like uniform updates
  76234. */
  76235. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76236. /**
  76237. * Set a mat3 in the shader from a Float32Array.
  76238. * @param name Define the name of the uniform as defined in the shader
  76239. * @param value Define the value to give to the uniform
  76240. * @return the material itself allowing "fluent" like uniform updates
  76241. */
  76242. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76243. /**
  76244. * Set a mat2 in the shader from a Float32Array.
  76245. * @param name Define the name of the uniform as defined in the shader
  76246. * @param value Define the value to give to the uniform
  76247. * @return the material itself allowing "fluent" like uniform updates
  76248. */
  76249. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76250. /**
  76251. * Set a vec2 array in the shader from a number array.
  76252. * @param name Define the name of the uniform as defined in the shader
  76253. * @param value Define the value to give to the uniform
  76254. * @return the material itself allowing "fluent" like uniform updates
  76255. */
  76256. setArray2(name: string, value: number[]): ShaderMaterial;
  76257. /**
  76258. * Set a vec3 array in the shader from a number array.
  76259. * @param name Define the name of the uniform as defined in the shader
  76260. * @param value Define the value to give to the uniform
  76261. * @return the material itself allowing "fluent" like uniform updates
  76262. */
  76263. setArray3(name: string, value: number[]): ShaderMaterial;
  76264. private _checkCache;
  76265. /**
  76266. * Specifies that the submesh is ready to be used
  76267. * @param mesh defines the mesh to check
  76268. * @param subMesh defines which submesh to check
  76269. * @param useInstances specifies that instances should be used
  76270. * @returns a boolean indicating that the submesh is ready or not
  76271. */
  76272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76273. /**
  76274. * Checks if the material is ready to render the requested mesh
  76275. * @param mesh Define the mesh to render
  76276. * @param useInstances Define whether or not the material is used with instances
  76277. * @returns true if ready, otherwise false
  76278. */
  76279. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76280. /**
  76281. * Binds the world matrix to the material
  76282. * @param world defines the world transformation matrix
  76283. */
  76284. bindOnlyWorldMatrix(world: Matrix): void;
  76285. /**
  76286. * Binds the material to the mesh
  76287. * @param world defines the world transformation matrix
  76288. * @param mesh defines the mesh to bind the material to
  76289. */
  76290. bind(world: Matrix, mesh?: Mesh): void;
  76291. /**
  76292. * Gets the active textures from the material
  76293. * @returns an array of textures
  76294. */
  76295. getActiveTextures(): BaseTexture[];
  76296. /**
  76297. * Specifies if the material uses a texture
  76298. * @param texture defines the texture to check against the material
  76299. * @returns a boolean specifying if the material uses the texture
  76300. */
  76301. hasTexture(texture: BaseTexture): boolean;
  76302. /**
  76303. * Makes a duplicate of the material, and gives it a new name
  76304. * @param name defines the new name for the duplicated material
  76305. * @returns the cloned material
  76306. */
  76307. clone(name: string): ShaderMaterial;
  76308. /**
  76309. * Disposes the material
  76310. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76311. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76312. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76313. */
  76314. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76315. /**
  76316. * Serializes this material in a JSON representation
  76317. * @returns the serialized material object
  76318. */
  76319. serialize(): any;
  76320. /**
  76321. * Creates a shader material from parsed shader material data
  76322. * @param source defines the JSON represnetation of the material
  76323. * @param scene defines the hosting scene
  76324. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76325. * @returns a new material
  76326. */
  76327. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76328. }
  76329. }
  76330. declare module BABYLON {
  76331. /** @hidden */
  76332. export var colorPixelShader: {
  76333. name: string;
  76334. shader: string;
  76335. };
  76336. }
  76337. declare module BABYLON {
  76338. /** @hidden */
  76339. export var colorVertexShader: {
  76340. name: string;
  76341. shader: string;
  76342. };
  76343. }
  76344. declare module BABYLON {
  76345. /**
  76346. * Line mesh
  76347. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76348. */
  76349. export class LinesMesh extends Mesh {
  76350. /**
  76351. * If vertex color should be applied to the mesh
  76352. */
  76353. useVertexColor?: boolean | undefined;
  76354. /**
  76355. * If vertex alpha should be applied to the mesh
  76356. */
  76357. useVertexAlpha?: boolean | undefined;
  76358. /**
  76359. * Color of the line (Default: White)
  76360. */
  76361. color: Color3;
  76362. /**
  76363. * Alpha of the line (Default: 1)
  76364. */
  76365. alpha: number;
  76366. /**
  76367. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76368. * This margin is expressed in world space coordinates, so its value may vary.
  76369. * Default value is 0.1
  76370. */
  76371. intersectionThreshold: number;
  76372. private _colorShader;
  76373. /**
  76374. * Creates a new LinesMesh
  76375. * @param name defines the name
  76376. * @param scene defines the hosting scene
  76377. * @param parent defines the parent mesh if any
  76378. * @param source defines the optional source LinesMesh used to clone data from
  76379. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76380. * When false, achieved by calling a clone(), also passing False.
  76381. * This will make creation of children, recursive.
  76382. * @param useVertexColor defines if this LinesMesh supports vertex color
  76383. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76384. */
  76385. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76386. /**
  76387. * If vertex color should be applied to the mesh
  76388. */
  76389. useVertexColor?: boolean | undefined,
  76390. /**
  76391. * If vertex alpha should be applied to the mesh
  76392. */
  76393. useVertexAlpha?: boolean | undefined);
  76394. private _addClipPlaneDefine;
  76395. private _removeClipPlaneDefine;
  76396. isReady(): boolean;
  76397. /**
  76398. * Returns the string "LineMesh"
  76399. */
  76400. getClassName(): string;
  76401. /**
  76402. * @hidden
  76403. */
  76404. /**
  76405. * @hidden
  76406. */
  76407. material: Material;
  76408. /**
  76409. * @hidden
  76410. */
  76411. readonly checkCollisions: boolean;
  76412. /** @hidden */
  76413. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76414. /** @hidden */
  76415. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76416. /**
  76417. * Disposes of the line mesh
  76418. * @param doNotRecurse If children should be disposed
  76419. */
  76420. dispose(doNotRecurse?: boolean): void;
  76421. /**
  76422. * Returns a new LineMesh object cloned from the current one.
  76423. */
  76424. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76425. /**
  76426. * Creates a new InstancedLinesMesh object from the mesh model.
  76427. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76428. * @param name defines the name of the new instance
  76429. * @returns a new InstancedLinesMesh
  76430. */
  76431. createInstance(name: string): InstancedLinesMesh;
  76432. }
  76433. /**
  76434. * Creates an instance based on a source LinesMesh
  76435. */
  76436. export class InstancedLinesMesh extends InstancedMesh {
  76437. /**
  76438. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76439. * This margin is expressed in world space coordinates, so its value may vary.
  76440. * Initilized with the intersectionThreshold value of the source LinesMesh
  76441. */
  76442. intersectionThreshold: number;
  76443. constructor(name: string, source: LinesMesh);
  76444. /**
  76445. * Returns the string "InstancedLinesMesh".
  76446. */
  76447. getClassName(): string;
  76448. }
  76449. }
  76450. declare module BABYLON {
  76451. /** @hidden */
  76452. export var linePixelShader: {
  76453. name: string;
  76454. shader: string;
  76455. };
  76456. }
  76457. declare module BABYLON {
  76458. /** @hidden */
  76459. export var lineVertexShader: {
  76460. name: string;
  76461. shader: string;
  76462. };
  76463. }
  76464. declare module BABYLON {
  76465. interface AbstractMesh {
  76466. /**
  76467. * Disables the mesh edge rendering mode
  76468. * @returns the currentAbstractMesh
  76469. */
  76470. disableEdgesRendering(): AbstractMesh;
  76471. /**
  76472. * Enables the edge rendering mode on the mesh.
  76473. * This mode makes the mesh edges visible
  76474. * @param epsilon defines the maximal distance between two angles to detect a face
  76475. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76476. * @returns the currentAbstractMesh
  76477. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76478. */
  76479. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76480. /**
  76481. * Gets the edgesRenderer associated with the mesh
  76482. */
  76483. edgesRenderer: Nullable<EdgesRenderer>;
  76484. }
  76485. interface LinesMesh {
  76486. /**
  76487. * Enables the edge rendering mode on the mesh.
  76488. * This mode makes the mesh edges visible
  76489. * @param epsilon defines the maximal distance between two angles to detect a face
  76490. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76491. * @returns the currentAbstractMesh
  76492. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76493. */
  76494. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76495. }
  76496. interface InstancedLinesMesh {
  76497. /**
  76498. * Enables the edge rendering mode on the mesh.
  76499. * This mode makes the mesh edges visible
  76500. * @param epsilon defines the maximal distance between two angles to detect a face
  76501. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76502. * @returns the current InstancedLinesMesh
  76503. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76504. */
  76505. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76506. }
  76507. /**
  76508. * Defines the minimum contract an Edges renderer should follow.
  76509. */
  76510. export interface IEdgesRenderer extends IDisposable {
  76511. /**
  76512. * Gets or sets a boolean indicating if the edgesRenderer is active
  76513. */
  76514. isEnabled: boolean;
  76515. /**
  76516. * Renders the edges of the attached mesh,
  76517. */
  76518. render(): void;
  76519. /**
  76520. * Checks wether or not the edges renderer is ready to render.
  76521. * @return true if ready, otherwise false.
  76522. */
  76523. isReady(): boolean;
  76524. }
  76525. /**
  76526. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76527. */
  76528. export class EdgesRenderer implements IEdgesRenderer {
  76529. /**
  76530. * Define the size of the edges with an orthographic camera
  76531. */
  76532. edgesWidthScalerForOrthographic: number;
  76533. /**
  76534. * Define the size of the edges with a perspective camera
  76535. */
  76536. edgesWidthScalerForPerspective: number;
  76537. protected _source: AbstractMesh;
  76538. protected _linesPositions: number[];
  76539. protected _linesNormals: number[];
  76540. protected _linesIndices: number[];
  76541. protected _epsilon: number;
  76542. protected _indicesCount: number;
  76543. protected _lineShader: ShaderMaterial;
  76544. protected _ib: WebGLBuffer;
  76545. protected _buffers: {
  76546. [key: string]: Nullable<VertexBuffer>;
  76547. };
  76548. protected _checkVerticesInsteadOfIndices: boolean;
  76549. private _meshRebuildObserver;
  76550. private _meshDisposeObserver;
  76551. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76552. isEnabled: boolean;
  76553. /**
  76554. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76555. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76556. * @param source Mesh used to create edges
  76557. * @param epsilon sum of angles in adjacency to check for edge
  76558. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76559. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76560. */
  76561. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76562. protected _prepareRessources(): void;
  76563. /** @hidden */
  76564. _rebuild(): void;
  76565. /**
  76566. * Releases the required resources for the edges renderer
  76567. */
  76568. dispose(): void;
  76569. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76570. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76571. /**
  76572. * Checks if the pair of p0 and p1 is en edge
  76573. * @param faceIndex
  76574. * @param edge
  76575. * @param faceNormals
  76576. * @param p0
  76577. * @param p1
  76578. * @private
  76579. */
  76580. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76581. /**
  76582. * push line into the position, normal and index buffer
  76583. * @protected
  76584. */
  76585. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76586. /**
  76587. * Generates lines edges from adjacencjes
  76588. * @private
  76589. */
  76590. _generateEdgesLines(): void;
  76591. /**
  76592. * Checks wether or not the edges renderer is ready to render.
  76593. * @return true if ready, otherwise false.
  76594. */
  76595. isReady(): boolean;
  76596. /**
  76597. * Renders the edges of the attached mesh,
  76598. */
  76599. render(): void;
  76600. }
  76601. /**
  76602. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76603. */
  76604. export class LineEdgesRenderer extends EdgesRenderer {
  76605. /**
  76606. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76607. * @param source LineMesh used to generate edges
  76608. * @param epsilon not important (specified angle for edge detection)
  76609. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76610. */
  76611. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76612. /**
  76613. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76614. */
  76615. _generateEdgesLines(): void;
  76616. }
  76617. }
  76618. declare module BABYLON {
  76619. /**
  76620. * This represents the object necessary to create a rendering group.
  76621. * This is exclusively used and created by the rendering manager.
  76622. * To modify the behavior, you use the available helpers in your scene or meshes.
  76623. * @hidden
  76624. */
  76625. export class RenderingGroup {
  76626. index: number;
  76627. private _scene;
  76628. private _opaqueSubMeshes;
  76629. private _transparentSubMeshes;
  76630. private _alphaTestSubMeshes;
  76631. private _depthOnlySubMeshes;
  76632. private _particleSystems;
  76633. private _spriteManagers;
  76634. private _opaqueSortCompareFn;
  76635. private _alphaTestSortCompareFn;
  76636. private _transparentSortCompareFn;
  76637. private _renderOpaque;
  76638. private _renderAlphaTest;
  76639. private _renderTransparent;
  76640. /** @hidden */
  76641. _edgesRenderers: SmartArray<IEdgesRenderer>;
  76642. onBeforeTransparentRendering: () => void;
  76643. /**
  76644. * Set the opaque sort comparison function.
  76645. * If null the sub meshes will be render in the order they were created
  76646. */
  76647. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76648. /**
  76649. * Set the alpha test sort comparison function.
  76650. * If null the sub meshes will be render in the order they were created
  76651. */
  76652. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76653. /**
  76654. * Set the transparent sort comparison function.
  76655. * If null the sub meshes will be render in the order they were created
  76656. */
  76657. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76658. /**
  76659. * Creates a new rendering group.
  76660. * @param index The rendering group index
  76661. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76662. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76663. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76664. */
  76665. 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>);
  76666. /**
  76667. * Render all the sub meshes contained in the group.
  76668. * @param customRenderFunction Used to override the default render behaviour of the group.
  76669. * @returns true if rendered some submeshes.
  76670. */
  76671. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76672. /**
  76673. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76674. * @param subMeshes The submeshes to render
  76675. */
  76676. private renderOpaqueSorted;
  76677. /**
  76678. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76679. * @param subMeshes The submeshes to render
  76680. */
  76681. private renderAlphaTestSorted;
  76682. /**
  76683. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76684. * @param subMeshes The submeshes to render
  76685. */
  76686. private renderTransparentSorted;
  76687. /**
  76688. * Renders the submeshes in a specified order.
  76689. * @param subMeshes The submeshes to sort before render
  76690. * @param sortCompareFn The comparison function use to sort
  76691. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76692. * @param transparent Specifies to activate blending if true
  76693. */
  76694. private static renderSorted;
  76695. /**
  76696. * Renders the submeshes in the order they were dispatched (no sort applied).
  76697. * @param subMeshes The submeshes to render
  76698. */
  76699. private static renderUnsorted;
  76700. /**
  76701. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76702. * are rendered back to front if in the same alpha index.
  76703. *
  76704. * @param a The first submesh
  76705. * @param b The second submesh
  76706. * @returns The result of the comparison
  76707. */
  76708. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76709. /**
  76710. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76711. * are rendered back to front.
  76712. *
  76713. * @param a The first submesh
  76714. * @param b The second submesh
  76715. * @returns The result of the comparison
  76716. */
  76717. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76718. /**
  76719. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76720. * are rendered front to back (prevent overdraw).
  76721. *
  76722. * @param a The first submesh
  76723. * @param b The second submesh
  76724. * @returns The result of the comparison
  76725. */
  76726. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76727. /**
  76728. * Resets the different lists of submeshes to prepare a new frame.
  76729. */
  76730. prepare(): void;
  76731. dispose(): void;
  76732. /**
  76733. * Inserts the submesh in its correct queue depending on its material.
  76734. * @param subMesh The submesh to dispatch
  76735. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76736. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76737. */
  76738. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76739. dispatchSprites(spriteManager: ISpriteManager): void;
  76740. dispatchParticles(particleSystem: IParticleSystem): void;
  76741. private _renderParticles;
  76742. private _renderSprites;
  76743. }
  76744. }
  76745. declare module BABYLON {
  76746. /**
  76747. * Interface describing the different options available in the rendering manager
  76748. * regarding Auto Clear between groups.
  76749. */
  76750. export interface IRenderingManagerAutoClearSetup {
  76751. /**
  76752. * Defines whether or not autoclear is enable.
  76753. */
  76754. autoClear: boolean;
  76755. /**
  76756. * Defines whether or not to autoclear the depth buffer.
  76757. */
  76758. depth: boolean;
  76759. /**
  76760. * Defines whether or not to autoclear the stencil buffer.
  76761. */
  76762. stencil: boolean;
  76763. }
  76764. /**
  76765. * This class is used by the onRenderingGroupObservable
  76766. */
  76767. export class RenderingGroupInfo {
  76768. /**
  76769. * The Scene that being rendered
  76770. */
  76771. scene: Scene;
  76772. /**
  76773. * The camera currently used for the rendering pass
  76774. */
  76775. camera: Nullable<Camera>;
  76776. /**
  76777. * The ID of the renderingGroup being processed
  76778. */
  76779. renderingGroupId: number;
  76780. }
  76781. /**
  76782. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76783. * It is enable to manage the different groups as well as the different necessary sort functions.
  76784. * This should not be used directly aside of the few static configurations
  76785. */
  76786. export class RenderingManager {
  76787. /**
  76788. * The max id used for rendering groups (not included)
  76789. */
  76790. static MAX_RENDERINGGROUPS: number;
  76791. /**
  76792. * The min id used for rendering groups (included)
  76793. */
  76794. static MIN_RENDERINGGROUPS: number;
  76795. /**
  76796. * Used to globally prevent autoclearing scenes.
  76797. */
  76798. static AUTOCLEAR: boolean;
  76799. /**
  76800. * @hidden
  76801. */
  76802. _useSceneAutoClearSetup: boolean;
  76803. private _scene;
  76804. private _renderingGroups;
  76805. private _depthStencilBufferAlreadyCleaned;
  76806. private _autoClearDepthStencil;
  76807. private _customOpaqueSortCompareFn;
  76808. private _customAlphaTestSortCompareFn;
  76809. private _customTransparentSortCompareFn;
  76810. private _renderingGroupInfo;
  76811. /**
  76812. * Instantiates a new rendering group for a particular scene
  76813. * @param scene Defines the scene the groups belongs to
  76814. */
  76815. constructor(scene: Scene);
  76816. private _clearDepthStencilBuffer;
  76817. /**
  76818. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76819. * @hidden
  76820. */
  76821. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76822. /**
  76823. * Resets the different information of the group to prepare a new frame
  76824. * @hidden
  76825. */
  76826. reset(): void;
  76827. /**
  76828. * Dispose and release the group and its associated resources.
  76829. * @hidden
  76830. */
  76831. dispose(): void;
  76832. /**
  76833. * Clear the info related to rendering groups preventing retention points during dispose.
  76834. */
  76835. freeRenderingGroups(): void;
  76836. private _prepareRenderingGroup;
  76837. /**
  76838. * Add a sprite manager to the rendering manager in order to render it this frame.
  76839. * @param spriteManager Define the sprite manager to render
  76840. */
  76841. dispatchSprites(spriteManager: ISpriteManager): void;
  76842. /**
  76843. * Add a particle system to the rendering manager in order to render it this frame.
  76844. * @param particleSystem Define the particle system to render
  76845. */
  76846. dispatchParticles(particleSystem: IParticleSystem): void;
  76847. /**
  76848. * Add a submesh to the manager in order to render it this frame
  76849. * @param subMesh The submesh to dispatch
  76850. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76851. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76852. */
  76853. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76854. /**
  76855. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76856. * This allowed control for front to back rendering or reversly depending of the special needs.
  76857. *
  76858. * @param renderingGroupId The rendering group id corresponding to its index
  76859. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  76860. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  76861. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  76862. */
  76863. 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;
  76864. /**
  76865. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  76866. *
  76867. * @param renderingGroupId The rendering group id corresponding to its index
  76868. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  76869. * @param depth Automatically clears depth between groups if true and autoClear is true.
  76870. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  76871. */
  76872. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  76873. /**
  76874. * Gets the current auto clear configuration for one rendering group of the rendering
  76875. * manager.
  76876. * @param index the rendering group index to get the information for
  76877. * @returns The auto clear setup for the requested rendering group
  76878. */
  76879. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  76880. }
  76881. }
  76882. declare module BABYLON {
  76883. /**
  76884. * This Helps creating a texture that will be created from a camera in your scene.
  76885. * It is basically a dynamic texture that could be used to create special effects for instance.
  76886. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  76887. */
  76888. export class RenderTargetTexture extends Texture {
  76889. isCube: boolean;
  76890. /**
  76891. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  76892. */
  76893. static readonly REFRESHRATE_RENDER_ONCE: number;
  76894. /**
  76895. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  76896. */
  76897. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  76898. /**
  76899. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  76900. * the central point of your effect and can save a lot of performances.
  76901. */
  76902. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  76903. /**
  76904. * Use this predicate to dynamically define the list of mesh you want to render.
  76905. * If set, the renderList property will be overwritten.
  76906. */
  76907. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  76908. private _renderList;
  76909. /**
  76910. * Use this list to define the list of mesh you want to render.
  76911. */
  76912. renderList: Nullable<Array<AbstractMesh>>;
  76913. private _hookArray;
  76914. /**
  76915. * Define if particles should be rendered in your texture.
  76916. */
  76917. renderParticles: boolean;
  76918. /**
  76919. * Define if sprites should be rendered in your texture.
  76920. */
  76921. renderSprites: boolean;
  76922. /**
  76923. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  76924. */
  76925. coordinatesMode: number;
  76926. /**
  76927. * Define the camera used to render the texture.
  76928. */
  76929. activeCamera: Nullable<Camera>;
  76930. /**
  76931. * Override the render function of the texture with your own one.
  76932. */
  76933. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  76934. /**
  76935. * Define if camera post processes should be use while rendering the texture.
  76936. */
  76937. useCameraPostProcesses: boolean;
  76938. /**
  76939. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  76940. */
  76941. ignoreCameraViewport: boolean;
  76942. private _postProcessManager;
  76943. private _postProcesses;
  76944. private _resizeObserver;
  76945. /**
  76946. * An event triggered when the texture is unbind.
  76947. */
  76948. onBeforeBindObservable: Observable<RenderTargetTexture>;
  76949. /**
  76950. * An event triggered when the texture is unbind.
  76951. */
  76952. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  76953. private _onAfterUnbindObserver;
  76954. /**
  76955. * Set a after unbind callback in the texture.
  76956. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  76957. */
  76958. onAfterUnbind: () => void;
  76959. /**
  76960. * An event triggered before rendering the texture
  76961. */
  76962. onBeforeRenderObservable: Observable<number>;
  76963. private _onBeforeRenderObserver;
  76964. /**
  76965. * Set a before render callback in the texture.
  76966. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  76967. */
  76968. onBeforeRender: (faceIndex: number) => void;
  76969. /**
  76970. * An event triggered after rendering the texture
  76971. */
  76972. onAfterRenderObservable: Observable<number>;
  76973. private _onAfterRenderObserver;
  76974. /**
  76975. * Set a after render callback in the texture.
  76976. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  76977. */
  76978. onAfterRender: (faceIndex: number) => void;
  76979. /**
  76980. * An event triggered after the texture clear
  76981. */
  76982. onClearObservable: Observable<Engine>;
  76983. private _onClearObserver;
  76984. /**
  76985. * Set a clear callback in the texture.
  76986. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  76987. */
  76988. onClear: (Engine: Engine) => void;
  76989. /**
  76990. * Define the clear color of the Render Target if it should be different from the scene.
  76991. */
  76992. clearColor: Color4;
  76993. protected _size: number | {
  76994. width: number;
  76995. height: number;
  76996. };
  76997. protected _initialSizeParameter: number | {
  76998. width: number;
  76999. height: number;
  77000. } | {
  77001. ratio: number;
  77002. };
  77003. protected _sizeRatio: Nullable<number>;
  77004. /** @hidden */
  77005. _generateMipMaps: boolean;
  77006. protected _renderingManager: RenderingManager;
  77007. /** @hidden */
  77008. _waitingRenderList: string[];
  77009. protected _doNotChangeAspectRatio: boolean;
  77010. protected _currentRefreshId: number;
  77011. protected _refreshRate: number;
  77012. protected _textureMatrix: Matrix;
  77013. protected _samples: number;
  77014. protected _renderTargetOptions: RenderTargetCreationOptions;
  77015. /**
  77016. * Gets render target creation options that were used.
  77017. */
  77018. readonly renderTargetOptions: RenderTargetCreationOptions;
  77019. protected _engine: Engine;
  77020. protected _onRatioRescale(): void;
  77021. /**
  77022. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77023. * It must define where the camera used to render the texture is set
  77024. */
  77025. boundingBoxPosition: Vector3;
  77026. private _boundingBoxSize;
  77027. /**
  77028. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77029. * When defined, the cubemap will switch to local mode
  77030. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77031. * @example https://www.babylonjs-playground.com/#RNASML
  77032. */
  77033. boundingBoxSize: Vector3;
  77034. /**
  77035. * In case the RTT has been created with a depth texture, get the associated
  77036. * depth texture.
  77037. * Otherwise, return null.
  77038. */
  77039. depthStencilTexture: Nullable<InternalTexture>;
  77040. /**
  77041. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77042. * or used a shadow, depth texture...
  77043. * @param name The friendly name of the texture
  77044. * @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)
  77045. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77046. * @param generateMipMaps True if mip maps need to be generated after render.
  77047. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77048. * @param type The type of the buffer in the RTT (int, half float, float...)
  77049. * @param isCube True if a cube texture needs to be created
  77050. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77051. * @param generateDepthBuffer True to generate a depth buffer
  77052. * @param generateStencilBuffer True to generate a stencil buffer
  77053. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77054. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77055. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77056. */
  77057. constructor(name: string, size: number | {
  77058. width: number;
  77059. height: number;
  77060. } | {
  77061. ratio: number;
  77062. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77063. /**
  77064. * Creates a depth stencil texture.
  77065. * This is only available in WebGL 2 or with the depth texture extension available.
  77066. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77067. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77068. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77069. */
  77070. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77071. private _processSizeParameter;
  77072. /**
  77073. * Define the number of samples to use in case of MSAA.
  77074. * It defaults to one meaning no MSAA has been enabled.
  77075. */
  77076. samples: number;
  77077. /**
  77078. * Resets the refresh counter of the texture and start bak from scratch.
  77079. * Could be useful to regenerate the texture if it is setup to render only once.
  77080. */
  77081. resetRefreshCounter(): void;
  77082. /**
  77083. * Define the refresh rate of the texture or the rendering frequency.
  77084. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77085. */
  77086. refreshRate: number;
  77087. /**
  77088. * Adds a post process to the render target rendering passes.
  77089. * @param postProcess define the post process to add
  77090. */
  77091. addPostProcess(postProcess: PostProcess): void;
  77092. /**
  77093. * Clear all the post processes attached to the render target
  77094. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77095. */
  77096. clearPostProcesses(dispose?: boolean): void;
  77097. /**
  77098. * Remove one of the post process from the list of attached post processes to the texture
  77099. * @param postProcess define the post process to remove from the list
  77100. */
  77101. removePostProcess(postProcess: PostProcess): void;
  77102. /** @hidden */
  77103. _shouldRender(): boolean;
  77104. /**
  77105. * Gets the actual render size of the texture.
  77106. * @returns the width of the render size
  77107. */
  77108. getRenderSize(): number;
  77109. /**
  77110. * Gets the actual render width of the texture.
  77111. * @returns the width of the render size
  77112. */
  77113. getRenderWidth(): number;
  77114. /**
  77115. * Gets the actual render height of the texture.
  77116. * @returns the height of the render size
  77117. */
  77118. getRenderHeight(): number;
  77119. /**
  77120. * Get if the texture can be rescaled or not.
  77121. */
  77122. readonly canRescale: boolean;
  77123. /**
  77124. * Resize the texture using a ratio.
  77125. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77126. */
  77127. scale(ratio: number): void;
  77128. /**
  77129. * Get the texture reflection matrix used to rotate/transform the reflection.
  77130. * @returns the reflection matrix
  77131. */
  77132. getReflectionTextureMatrix(): Matrix;
  77133. /**
  77134. * Resize the texture to a new desired size.
  77135. * Be carrefull as it will recreate all the data in the new texture.
  77136. * @param size Define the new size. It can be:
  77137. * - a number for squared texture,
  77138. * - an object containing { width: number, height: number }
  77139. * - or an object containing a ratio { ratio: number }
  77140. */
  77141. resize(size: number | {
  77142. width: number;
  77143. height: number;
  77144. } | {
  77145. ratio: number;
  77146. }): void;
  77147. /**
  77148. * Renders all the objects from the render list into the texture.
  77149. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77150. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77151. */
  77152. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77153. private _bestReflectionRenderTargetDimension;
  77154. /**
  77155. * @hidden
  77156. * @param faceIndex face index to bind to if this is a cubetexture
  77157. */
  77158. _bindFrameBuffer(faceIndex?: number): void;
  77159. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77160. private renderToTarget;
  77161. /**
  77162. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77163. * This allowed control for front to back rendering or reversly depending of the special needs.
  77164. *
  77165. * @param renderingGroupId The rendering group id corresponding to its index
  77166. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77167. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77168. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77169. */
  77170. 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;
  77171. /**
  77172. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77173. *
  77174. * @param renderingGroupId The rendering group id corresponding to its index
  77175. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77176. */
  77177. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77178. /**
  77179. * Clones the texture.
  77180. * @returns the cloned texture
  77181. */
  77182. clone(): RenderTargetTexture;
  77183. /**
  77184. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77185. * @returns The JSON representation of the texture
  77186. */
  77187. serialize(): any;
  77188. /**
  77189. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77190. */
  77191. disposeFramebufferObjects(): void;
  77192. /**
  77193. * Dispose the texture and release its associated resources.
  77194. */
  77195. dispose(): void;
  77196. /** @hidden */
  77197. _rebuild(): void;
  77198. /**
  77199. * Clear the info related to rendering groups preventing retention point in material dispose.
  77200. */
  77201. freeRenderingGroups(): void;
  77202. /**
  77203. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77204. * @returns the view count
  77205. */
  77206. getViewCount(): number;
  77207. }
  77208. }
  77209. declare module BABYLON {
  77210. /**
  77211. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77212. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77213. * You can then easily use it as a reflectionTexture on a flat surface.
  77214. * In case the surface is not a plane, please consider relying on reflection probes.
  77215. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77216. */
  77217. export class MirrorTexture extends RenderTargetTexture {
  77218. private scene;
  77219. /**
  77220. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77221. * 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.
  77222. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77223. */
  77224. mirrorPlane: Plane;
  77225. /**
  77226. * Define the blur ratio used to blur the reflection if needed.
  77227. */
  77228. blurRatio: number;
  77229. /**
  77230. * Define the adaptive blur kernel used to blur the reflection if needed.
  77231. * This will autocompute the closest best match for the `blurKernel`
  77232. */
  77233. adaptiveBlurKernel: number;
  77234. /**
  77235. * Define the blur kernel used to blur the reflection if needed.
  77236. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77237. */
  77238. blurKernel: number;
  77239. /**
  77240. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77241. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77242. */
  77243. blurKernelX: number;
  77244. /**
  77245. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77246. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77247. */
  77248. blurKernelY: number;
  77249. private _autoComputeBlurKernel;
  77250. protected _onRatioRescale(): void;
  77251. private _updateGammaSpace;
  77252. private _imageProcessingConfigChangeObserver;
  77253. private _transformMatrix;
  77254. private _mirrorMatrix;
  77255. private _savedViewMatrix;
  77256. private _blurX;
  77257. private _blurY;
  77258. private _adaptiveBlurKernel;
  77259. private _blurKernelX;
  77260. private _blurKernelY;
  77261. private _blurRatio;
  77262. /**
  77263. * Instantiates a Mirror Texture.
  77264. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77265. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77266. * You can then easily use it as a reflectionTexture on a flat surface.
  77267. * In case the surface is not a plane, please consider relying on reflection probes.
  77268. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77269. * @param name
  77270. * @param size
  77271. * @param scene
  77272. * @param generateMipMaps
  77273. * @param type
  77274. * @param samplingMode
  77275. * @param generateDepthBuffer
  77276. */
  77277. constructor(name: string, size: number | {
  77278. width: number;
  77279. height: number;
  77280. } | {
  77281. ratio: number;
  77282. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77283. private _preparePostProcesses;
  77284. /**
  77285. * Clone the mirror texture.
  77286. * @returns the cloned texture
  77287. */
  77288. clone(): MirrorTexture;
  77289. /**
  77290. * Serialize the texture to a JSON representation you could use in Parse later on
  77291. * @returns the serialized JSON representation
  77292. */
  77293. serialize(): any;
  77294. /**
  77295. * Dispose the texture and release its associated resources.
  77296. */
  77297. dispose(): void;
  77298. }
  77299. }
  77300. declare module BABYLON {
  77301. /**
  77302. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77303. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77304. */
  77305. export class Texture extends BaseTexture {
  77306. /** @hidden */
  77307. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77308. /** @hidden */
  77309. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77310. /** @hidden */
  77311. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77312. /** nearest is mag = nearest and min = nearest and mip = linear */
  77313. static readonly NEAREST_SAMPLINGMODE: number;
  77314. /** nearest is mag = nearest and min = nearest and mip = linear */
  77315. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77316. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77317. static readonly BILINEAR_SAMPLINGMODE: number;
  77318. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77319. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77320. /** Trilinear is mag = linear and min = linear and mip = linear */
  77321. static readonly TRILINEAR_SAMPLINGMODE: number;
  77322. /** Trilinear is mag = linear and min = linear and mip = linear */
  77323. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77324. /** mag = nearest and min = nearest and mip = nearest */
  77325. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77326. /** mag = nearest and min = linear and mip = nearest */
  77327. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77328. /** mag = nearest and min = linear and mip = linear */
  77329. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77330. /** mag = nearest and min = linear and mip = none */
  77331. static readonly NEAREST_LINEAR: number;
  77332. /** mag = nearest and min = nearest and mip = none */
  77333. static readonly NEAREST_NEAREST: number;
  77334. /** mag = linear and min = nearest and mip = nearest */
  77335. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77336. /** mag = linear and min = nearest and mip = linear */
  77337. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77338. /** mag = linear and min = linear and mip = none */
  77339. static readonly LINEAR_LINEAR: number;
  77340. /** mag = linear and min = nearest and mip = none */
  77341. static readonly LINEAR_NEAREST: number;
  77342. /** Explicit coordinates mode */
  77343. static readonly EXPLICIT_MODE: number;
  77344. /** Spherical coordinates mode */
  77345. static readonly SPHERICAL_MODE: number;
  77346. /** Planar coordinates mode */
  77347. static readonly PLANAR_MODE: number;
  77348. /** Cubic coordinates mode */
  77349. static readonly CUBIC_MODE: number;
  77350. /** Projection coordinates mode */
  77351. static readonly PROJECTION_MODE: number;
  77352. /** Inverse Cubic coordinates mode */
  77353. static readonly SKYBOX_MODE: number;
  77354. /** Inverse Cubic coordinates mode */
  77355. static readonly INVCUBIC_MODE: number;
  77356. /** Equirectangular coordinates mode */
  77357. static readonly EQUIRECTANGULAR_MODE: number;
  77358. /** Equirectangular Fixed coordinates mode */
  77359. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77360. /** Equirectangular Fixed Mirrored coordinates mode */
  77361. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77362. /** Texture is not repeating outside of 0..1 UVs */
  77363. static readonly CLAMP_ADDRESSMODE: number;
  77364. /** Texture is repeating outside of 0..1 UVs */
  77365. static readonly WRAP_ADDRESSMODE: number;
  77366. /** Texture is repeating and mirrored */
  77367. static readonly MIRROR_ADDRESSMODE: number;
  77368. /**
  77369. * 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
  77370. */
  77371. static UseSerializedUrlIfAny: boolean;
  77372. /**
  77373. * Define the url of the texture.
  77374. */
  77375. url: Nullable<string>;
  77376. /**
  77377. * Define an offset on the texture to offset the u coordinates of the UVs
  77378. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77379. */
  77380. uOffset: number;
  77381. /**
  77382. * Define an offset on the texture to offset the v coordinates of the UVs
  77383. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77384. */
  77385. vOffset: number;
  77386. /**
  77387. * Define an offset on the texture to scale the u coordinates of the UVs
  77388. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77389. */
  77390. uScale: number;
  77391. /**
  77392. * Define an offset on the texture to scale the v coordinates of the UVs
  77393. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77394. */
  77395. vScale: number;
  77396. /**
  77397. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77398. * @see http://doc.babylonjs.com/how_to/more_materials
  77399. */
  77400. uAng: number;
  77401. /**
  77402. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77403. * @see http://doc.babylonjs.com/how_to/more_materials
  77404. */
  77405. vAng: number;
  77406. /**
  77407. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77408. * @see http://doc.babylonjs.com/how_to/more_materials
  77409. */
  77410. wAng: number;
  77411. /**
  77412. * Defines the center of rotation (U)
  77413. */
  77414. uRotationCenter: number;
  77415. /**
  77416. * Defines the center of rotation (V)
  77417. */
  77418. vRotationCenter: number;
  77419. /**
  77420. * Defines the center of rotation (W)
  77421. */
  77422. wRotationCenter: number;
  77423. /**
  77424. * Are mip maps generated for this texture or not.
  77425. */
  77426. readonly noMipmap: boolean;
  77427. /**
  77428. * List of inspectable custom properties (used by the Inspector)
  77429. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77430. */
  77431. inspectableCustomProperties: Nullable<IInspectable[]>;
  77432. private _noMipmap;
  77433. /** @hidden */
  77434. _invertY: boolean;
  77435. private _rowGenerationMatrix;
  77436. private _cachedTextureMatrix;
  77437. private _projectionModeMatrix;
  77438. private _t0;
  77439. private _t1;
  77440. private _t2;
  77441. private _cachedUOffset;
  77442. private _cachedVOffset;
  77443. private _cachedUScale;
  77444. private _cachedVScale;
  77445. private _cachedUAng;
  77446. private _cachedVAng;
  77447. private _cachedWAng;
  77448. private _cachedProjectionMatrixId;
  77449. private _cachedCoordinatesMode;
  77450. /** @hidden */
  77451. protected _initialSamplingMode: number;
  77452. /** @hidden */
  77453. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77454. private _deleteBuffer;
  77455. protected _format: Nullable<number>;
  77456. private _delayedOnLoad;
  77457. private _delayedOnError;
  77458. /**
  77459. * Observable triggered once the texture has been loaded.
  77460. */
  77461. onLoadObservable: Observable<Texture>;
  77462. protected _isBlocking: boolean;
  77463. /**
  77464. * Is the texture preventing material to render while loading.
  77465. * If false, a default texture will be used instead of the loading one during the preparation step.
  77466. */
  77467. isBlocking: boolean;
  77468. /**
  77469. * Get the current sampling mode associated with the texture.
  77470. */
  77471. readonly samplingMode: number;
  77472. /**
  77473. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77474. */
  77475. readonly invertY: boolean;
  77476. /**
  77477. * Instantiates a new texture.
  77478. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77479. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77480. * @param url define the url of the picture to load as a texture
  77481. * @param scene define the scene the texture will belong to
  77482. * @param noMipmap define if the texture will require mip maps or not
  77483. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77484. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77485. * @param onLoad define a callback triggered when the texture has been loaded
  77486. * @param onError define a callback triggered when an error occurred during the loading session
  77487. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77488. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77489. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77490. */
  77491. 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);
  77492. /**
  77493. * Update the url (and optional buffer) of this texture if url was null during construction.
  77494. * @param url the url of the texture
  77495. * @param buffer the buffer of the texture (defaults to null)
  77496. * @param onLoad callback called when the texture is loaded (defaults to null)
  77497. */
  77498. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77499. /**
  77500. * Finish the loading sequence of a texture flagged as delayed load.
  77501. * @hidden
  77502. */
  77503. delayLoad(): void;
  77504. private _prepareRowForTextureGeneration;
  77505. /**
  77506. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77507. * @returns the transform matrix of the texture.
  77508. */
  77509. getTextureMatrix(): Matrix;
  77510. /**
  77511. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77512. * @returns The reflection texture transform
  77513. */
  77514. getReflectionTextureMatrix(): Matrix;
  77515. /**
  77516. * Clones the texture.
  77517. * @returns the cloned texture
  77518. */
  77519. clone(): Texture;
  77520. /**
  77521. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77522. * @returns The JSON representation of the texture
  77523. */
  77524. serialize(): any;
  77525. /**
  77526. * Get the current class name of the texture useful for serialization or dynamic coding.
  77527. * @returns "Texture"
  77528. */
  77529. getClassName(): string;
  77530. /**
  77531. * Dispose the texture and release its associated resources.
  77532. */
  77533. dispose(): void;
  77534. /**
  77535. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77536. * @param parsedTexture Define the JSON representation of the texture
  77537. * @param scene Define the scene the parsed texture should be instantiated in
  77538. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77539. * @returns The parsed texture if successful
  77540. */
  77541. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77542. /**
  77543. * Creates a texture from its base 64 representation.
  77544. * @param data Define the base64 payload without the data: prefix
  77545. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77546. * @param scene Define the scene the texture should belong to
  77547. * @param noMipmap Forces the texture to not create mip map information if true
  77548. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77549. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77550. * @param onLoad define a callback triggered when the texture has been loaded
  77551. * @param onError define a callback triggered when an error occurred during the loading session
  77552. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77553. * @returns the created texture
  77554. */
  77555. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77556. /**
  77557. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77558. * @param data Define the base64 payload without the data: prefix
  77559. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77560. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77561. * @param scene Define the scene the texture should belong to
  77562. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77563. * @param noMipmap Forces the texture to not create mip map information if true
  77564. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77565. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77566. * @param onLoad define a callback triggered when the texture has been loaded
  77567. * @param onError define a callback triggered when an error occurred during the loading session
  77568. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77569. * @returns the created texture
  77570. */
  77571. 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;
  77572. }
  77573. }
  77574. declare module BABYLON {
  77575. /**
  77576. * Raw texture can help creating a texture directly from an array of data.
  77577. * This can be super useful if you either get the data from an uncompressed source or
  77578. * if you wish to create your texture pixel by pixel.
  77579. */
  77580. export class RawTexture extends Texture {
  77581. /**
  77582. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77583. */
  77584. format: number;
  77585. private _engine;
  77586. /**
  77587. * Instantiates a new RawTexture.
  77588. * Raw texture can help creating a texture directly from an array of data.
  77589. * This can be super useful if you either get the data from an uncompressed source or
  77590. * if you wish to create your texture pixel by pixel.
  77591. * @param data define the array of data to use to create the texture
  77592. * @param width define the width of the texture
  77593. * @param height define the height of the texture
  77594. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77595. * @param scene define the scene the texture belongs to
  77596. * @param generateMipMaps define whether mip maps should be generated or not
  77597. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77598. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77599. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77600. */
  77601. constructor(data: ArrayBufferView, width: number, height: number,
  77602. /**
  77603. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77604. */
  77605. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77606. /**
  77607. * Updates the texture underlying data.
  77608. * @param data Define the new data of the texture
  77609. */
  77610. update(data: ArrayBufferView): void;
  77611. /**
  77612. * Creates a luminance texture from some data.
  77613. * @param data Define the texture data
  77614. * @param width Define the width of the texture
  77615. * @param height Define the height of the texture
  77616. * @param scene Define the scene the texture belongs to
  77617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77620. * @returns the luminance texture
  77621. */
  77622. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77623. /**
  77624. * Creates a luminance alpha texture from some data.
  77625. * @param data Define the texture data
  77626. * @param width Define the width of the texture
  77627. * @param height Define the height of the texture
  77628. * @param scene Define the scene the texture belongs to
  77629. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77630. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77631. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77632. * @returns the luminance alpha texture
  77633. */
  77634. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77635. /**
  77636. * Creates an alpha texture from some data.
  77637. * @param data Define the texture data
  77638. * @param width Define the width of the texture
  77639. * @param height Define the height of the texture
  77640. * @param scene Define the scene the texture belongs to
  77641. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77642. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77643. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77644. * @returns the alpha texture
  77645. */
  77646. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77647. /**
  77648. * Creates a RGB texture from some data.
  77649. * @param data Define the texture data
  77650. * @param width Define the width of the texture
  77651. * @param height Define the height of the texture
  77652. * @param scene Define the scene the texture belongs to
  77653. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77654. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77655. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77656. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77657. * @returns the RGB alpha texture
  77658. */
  77659. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77660. /**
  77661. * Creates a RGBA texture from some data.
  77662. * @param data Define the texture data
  77663. * @param width Define the width of the texture
  77664. * @param height Define the height of the texture
  77665. * @param scene Define the scene the texture belongs to
  77666. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77667. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77668. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77669. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77670. * @returns the RGBA texture
  77671. */
  77672. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77673. /**
  77674. * Creates a R texture from some data.
  77675. * @param data Define the texture data
  77676. * @param width Define the width of the texture
  77677. * @param height Define the height of the texture
  77678. * @param scene Define the scene the texture belongs to
  77679. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77680. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77681. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77682. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77683. * @returns the R texture
  77684. */
  77685. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77686. }
  77687. }
  77688. declare module BABYLON {
  77689. /**
  77690. * Defines a runtime animation
  77691. */
  77692. export class RuntimeAnimation {
  77693. private _events;
  77694. /**
  77695. * The current frame of the runtime animation
  77696. */
  77697. private _currentFrame;
  77698. /**
  77699. * The animation used by the runtime animation
  77700. */
  77701. private _animation;
  77702. /**
  77703. * The target of the runtime animation
  77704. */
  77705. private _target;
  77706. /**
  77707. * The initiating animatable
  77708. */
  77709. private _host;
  77710. /**
  77711. * The original value of the runtime animation
  77712. */
  77713. private _originalValue;
  77714. /**
  77715. * The original blend value of the runtime animation
  77716. */
  77717. private _originalBlendValue;
  77718. /**
  77719. * The offsets cache of the runtime animation
  77720. */
  77721. private _offsetsCache;
  77722. /**
  77723. * The high limits cache of the runtime animation
  77724. */
  77725. private _highLimitsCache;
  77726. /**
  77727. * Specifies if the runtime animation has been stopped
  77728. */
  77729. private _stopped;
  77730. /**
  77731. * The blending factor of the runtime animation
  77732. */
  77733. private _blendingFactor;
  77734. /**
  77735. * The BabylonJS scene
  77736. */
  77737. private _scene;
  77738. /**
  77739. * The current value of the runtime animation
  77740. */
  77741. private _currentValue;
  77742. /** @hidden */
  77743. _animationState: _IAnimationState;
  77744. /**
  77745. * The active target of the runtime animation
  77746. */
  77747. private _activeTargets;
  77748. private _currentActiveTarget;
  77749. private _directTarget;
  77750. /**
  77751. * The target path of the runtime animation
  77752. */
  77753. private _targetPath;
  77754. /**
  77755. * The weight of the runtime animation
  77756. */
  77757. private _weight;
  77758. /**
  77759. * The ratio offset of the runtime animation
  77760. */
  77761. private _ratioOffset;
  77762. /**
  77763. * The previous delay of the runtime animation
  77764. */
  77765. private _previousDelay;
  77766. /**
  77767. * The previous ratio of the runtime animation
  77768. */
  77769. private _previousRatio;
  77770. private _enableBlending;
  77771. private _keys;
  77772. private _minFrame;
  77773. private _maxFrame;
  77774. private _minValue;
  77775. private _maxValue;
  77776. private _targetIsArray;
  77777. /**
  77778. * Gets the current frame of the runtime animation
  77779. */
  77780. readonly currentFrame: number;
  77781. /**
  77782. * Gets the weight of the runtime animation
  77783. */
  77784. readonly weight: number;
  77785. /**
  77786. * Gets the current value of the runtime animation
  77787. */
  77788. readonly currentValue: any;
  77789. /**
  77790. * Gets the target path of the runtime animation
  77791. */
  77792. readonly targetPath: string;
  77793. /**
  77794. * Gets the actual target of the runtime animation
  77795. */
  77796. readonly target: any;
  77797. /** @hidden */
  77798. _onLoop: () => void;
  77799. /**
  77800. * Create a new RuntimeAnimation object
  77801. * @param target defines the target of the animation
  77802. * @param animation defines the source animation object
  77803. * @param scene defines the hosting scene
  77804. * @param host defines the initiating Animatable
  77805. */
  77806. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  77807. private _preparePath;
  77808. /**
  77809. * Gets the animation from the runtime animation
  77810. */
  77811. readonly animation: Animation;
  77812. /**
  77813. * Resets the runtime animation to the beginning
  77814. * @param restoreOriginal defines whether to restore the target property to the original value
  77815. */
  77816. reset(restoreOriginal?: boolean): void;
  77817. /**
  77818. * Specifies if the runtime animation is stopped
  77819. * @returns Boolean specifying if the runtime animation is stopped
  77820. */
  77821. isStopped(): boolean;
  77822. /**
  77823. * Disposes of the runtime animation
  77824. */
  77825. dispose(): void;
  77826. /**
  77827. * Apply the interpolated value to the target
  77828. * @param currentValue defines the value computed by the animation
  77829. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  77830. */
  77831. setValue(currentValue: any, weight: number): void;
  77832. private _getOriginalValues;
  77833. private _setValue;
  77834. /**
  77835. * Gets the loop pmode of the runtime animation
  77836. * @returns Loop Mode
  77837. */
  77838. private _getCorrectLoopMode;
  77839. /**
  77840. * Move the current animation to a given frame
  77841. * @param frame defines the frame to move to
  77842. */
  77843. goToFrame(frame: number): void;
  77844. /**
  77845. * @hidden Internal use only
  77846. */
  77847. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  77848. /**
  77849. * Execute the current animation
  77850. * @param delay defines the delay to add to the current frame
  77851. * @param from defines the lower bound of the animation range
  77852. * @param to defines the upper bound of the animation range
  77853. * @param loop defines if the current animation must loop
  77854. * @param speedRatio defines the current speed ratio
  77855. * @param weight defines the weight of the animation (default is -1 so no weight)
  77856. * @param onLoop optional callback called when animation loops
  77857. * @returns a boolean indicating if the animation is running
  77858. */
  77859. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  77860. }
  77861. }
  77862. declare module BABYLON {
  77863. /**
  77864. * Class used to store an actual running animation
  77865. */
  77866. export class Animatable {
  77867. /** defines the target object */
  77868. target: any;
  77869. /** defines the starting frame number (default is 0) */
  77870. fromFrame: number;
  77871. /** defines the ending frame number (default is 100) */
  77872. toFrame: number;
  77873. /** defines if the animation must loop (default is false) */
  77874. loopAnimation: boolean;
  77875. /** defines a callback to call when animation ends if it is not looping */
  77876. onAnimationEnd?: (() => void) | null | undefined;
  77877. /** defines a callback to call when animation loops */
  77878. onAnimationLoop?: (() => void) | null | undefined;
  77879. private _localDelayOffset;
  77880. private _pausedDelay;
  77881. private _runtimeAnimations;
  77882. private _paused;
  77883. private _scene;
  77884. private _speedRatio;
  77885. private _weight;
  77886. private _syncRoot;
  77887. /**
  77888. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  77889. * This will only apply for non looping animation (default is true)
  77890. */
  77891. disposeOnEnd: boolean;
  77892. /**
  77893. * Gets a boolean indicating if the animation has started
  77894. */
  77895. animationStarted: boolean;
  77896. /**
  77897. * Observer raised when the animation ends
  77898. */
  77899. onAnimationEndObservable: Observable<Animatable>;
  77900. /**
  77901. * Observer raised when the animation loops
  77902. */
  77903. onAnimationLoopObservable: Observable<Animatable>;
  77904. /**
  77905. * Gets the root Animatable used to synchronize and normalize animations
  77906. */
  77907. readonly syncRoot: Nullable<Animatable>;
  77908. /**
  77909. * Gets the current frame of the first RuntimeAnimation
  77910. * Used to synchronize Animatables
  77911. */
  77912. readonly masterFrame: number;
  77913. /**
  77914. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  77915. */
  77916. weight: number;
  77917. /**
  77918. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  77919. */
  77920. speedRatio: number;
  77921. /**
  77922. * Creates a new Animatable
  77923. * @param scene defines the hosting scene
  77924. * @param target defines the target object
  77925. * @param fromFrame defines the starting frame number (default is 0)
  77926. * @param toFrame defines the ending frame number (default is 100)
  77927. * @param loopAnimation defines if the animation must loop (default is false)
  77928. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  77929. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  77930. * @param animations defines a group of animation to add to the new Animatable
  77931. * @param onAnimationLoop defines a callback to call when animation loops
  77932. */
  77933. constructor(scene: Scene,
  77934. /** defines the target object */
  77935. target: any,
  77936. /** defines the starting frame number (default is 0) */
  77937. fromFrame?: number,
  77938. /** defines the ending frame number (default is 100) */
  77939. toFrame?: number,
  77940. /** defines if the animation must loop (default is false) */
  77941. loopAnimation?: boolean, speedRatio?: number,
  77942. /** defines a callback to call when animation ends if it is not looping */
  77943. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  77944. /** defines a callback to call when animation loops */
  77945. onAnimationLoop?: (() => void) | null | undefined);
  77946. /**
  77947. * Synchronize and normalize current Animatable with a source Animatable
  77948. * This is useful when using animation weights and when animations are not of the same length
  77949. * @param root defines the root Animatable to synchronize with
  77950. * @returns the current Animatable
  77951. */
  77952. syncWith(root: Animatable): Animatable;
  77953. /**
  77954. * Gets the list of runtime animations
  77955. * @returns an array of RuntimeAnimation
  77956. */
  77957. getAnimations(): RuntimeAnimation[];
  77958. /**
  77959. * Adds more animations to the current animatable
  77960. * @param target defines the target of the animations
  77961. * @param animations defines the new animations to add
  77962. */
  77963. appendAnimations(target: any, animations: Animation[]): void;
  77964. /**
  77965. * Gets the source animation for a specific property
  77966. * @param property defines the propertyu to look for
  77967. * @returns null or the source animation for the given property
  77968. */
  77969. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  77970. /**
  77971. * Gets the runtime animation for a specific property
  77972. * @param property defines the propertyu to look for
  77973. * @returns null or the runtime animation for the given property
  77974. */
  77975. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  77976. /**
  77977. * Resets the animatable to its original state
  77978. */
  77979. reset(): void;
  77980. /**
  77981. * Allows the animatable to blend with current running animations
  77982. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77983. * @param blendingSpeed defines the blending speed to use
  77984. */
  77985. enableBlending(blendingSpeed: number): void;
  77986. /**
  77987. * Disable animation blending
  77988. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  77989. */
  77990. disableBlending(): void;
  77991. /**
  77992. * Jump directly to a given frame
  77993. * @param frame defines the frame to jump to
  77994. */
  77995. goToFrame(frame: number): void;
  77996. /**
  77997. * Pause the animation
  77998. */
  77999. pause(): void;
  78000. /**
  78001. * Restart the animation
  78002. */
  78003. restart(): void;
  78004. private _raiseOnAnimationEnd;
  78005. /**
  78006. * Stop and delete the current animation
  78007. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78008. * @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)
  78009. */
  78010. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78011. /**
  78012. * Wait asynchronously for the animation to end
  78013. * @returns a promise which will be fullfilled when the animation ends
  78014. */
  78015. waitAsync(): Promise<Animatable>;
  78016. /** @hidden */
  78017. _animate(delay: number): boolean;
  78018. }
  78019. interface Scene {
  78020. /** @hidden */
  78021. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78022. /** @hidden */
  78023. _processLateAnimationBindingsForMatrices(holder: {
  78024. totalWeight: number;
  78025. animations: RuntimeAnimation[];
  78026. originalValue: Matrix;
  78027. }): any;
  78028. /** @hidden */
  78029. _processLateAnimationBindingsForQuaternions(holder: {
  78030. totalWeight: number;
  78031. animations: RuntimeAnimation[];
  78032. originalValue: Quaternion;
  78033. }, refQuaternion: Quaternion): Quaternion;
  78034. /** @hidden */
  78035. _processLateAnimationBindings(): void;
  78036. /**
  78037. * Will start the animation sequence of a given target
  78038. * @param target defines the target
  78039. * @param from defines from which frame should animation start
  78040. * @param to defines until which frame should animation run.
  78041. * @param weight defines the weight to apply to the animation (1.0 by default)
  78042. * @param loop defines if the animation loops
  78043. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78044. * @param onAnimationEnd defines the function to be executed when the animation ends
  78045. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78046. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78047. * @param onAnimationLoop defines the callback to call when an animation loops
  78048. * @returns the animatable object created for this animation
  78049. */
  78050. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78051. /**
  78052. * Will start the animation sequence of a given target
  78053. * @param target defines the target
  78054. * @param from defines from which frame should animation start
  78055. * @param to defines until which frame should animation run.
  78056. * @param loop defines if the animation loops
  78057. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78058. * @param onAnimationEnd defines the function to be executed when the animation ends
  78059. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78060. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78061. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78062. * @param onAnimationLoop defines the callback to call when an animation loops
  78063. * @returns the animatable object created for this animation
  78064. */
  78065. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78066. /**
  78067. * Will start the animation sequence of a given target and its hierarchy
  78068. * @param target defines the target
  78069. * @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.
  78070. * @param from defines from which frame should animation start
  78071. * @param to defines until which frame should animation run.
  78072. * @param loop defines if the animation loops
  78073. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78074. * @param onAnimationEnd defines the function to be executed when the animation ends
  78075. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78076. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78077. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78078. * @param onAnimationLoop defines the callback to call when an animation loops
  78079. * @returns the list of created animatables
  78080. */
  78081. 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[];
  78082. /**
  78083. * Begin a new animation on a given node
  78084. * @param target defines the target where the animation will take place
  78085. * @param animations defines the list of animations to start
  78086. * @param from defines the initial value
  78087. * @param to defines the final value
  78088. * @param loop defines if you want animation to loop (off by default)
  78089. * @param speedRatio defines the speed ratio to apply to all animations
  78090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78091. * @param onAnimationLoop defines the callback to call when an animation loops
  78092. * @returns the list of created animatables
  78093. */
  78094. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78095. /**
  78096. * Begin a new animation on a given node and its hierarchy
  78097. * @param target defines the root node where the animation will take place
  78098. * @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.
  78099. * @param animations defines the list of animations to start
  78100. * @param from defines the initial value
  78101. * @param to defines the final value
  78102. * @param loop defines if you want animation to loop (off by default)
  78103. * @param speedRatio defines the speed ratio to apply to all animations
  78104. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78105. * @param onAnimationLoop defines the callback to call when an animation loops
  78106. * @returns the list of animatables created for all nodes
  78107. */
  78108. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78109. /**
  78110. * Gets the animatable associated with a specific target
  78111. * @param target defines the target of the animatable
  78112. * @returns the required animatable if found
  78113. */
  78114. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78115. /**
  78116. * Gets all animatables associated with a given target
  78117. * @param target defines the target to look animatables for
  78118. * @returns an array of Animatables
  78119. */
  78120. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78121. /**
  78122. * Will stop the animation of the given target
  78123. * @param target - the target
  78124. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78125. * @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)
  78126. */
  78127. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78128. /**
  78129. * Stops and removes all animations that have been applied to the scene
  78130. */
  78131. stopAllAnimations(): void;
  78132. }
  78133. interface Bone {
  78134. /**
  78135. * Copy an animation range from another bone
  78136. * @param source defines the source bone
  78137. * @param rangeName defines the range name to copy
  78138. * @param frameOffset defines the frame offset
  78139. * @param rescaleAsRequired defines if rescaling must be applied if required
  78140. * @param skelDimensionsRatio defines the scaling ratio
  78141. * @returns true if operation was successful
  78142. */
  78143. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78144. }
  78145. }
  78146. declare module BABYLON {
  78147. /**
  78148. * Class used to handle skinning animations
  78149. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78150. */
  78151. export class Skeleton implements IAnimatable {
  78152. /** defines the skeleton name */
  78153. name: string;
  78154. /** defines the skeleton Id */
  78155. id: string;
  78156. /**
  78157. * Defines the list of child bones
  78158. */
  78159. bones: Bone[];
  78160. /**
  78161. * Defines an estimate of the dimension of the skeleton at rest
  78162. */
  78163. dimensionsAtRest: Vector3;
  78164. /**
  78165. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78166. */
  78167. needInitialSkinMatrix: boolean;
  78168. /**
  78169. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78170. */
  78171. overrideMesh: Nullable<AbstractMesh>;
  78172. /**
  78173. * Gets the list of animations attached to this skeleton
  78174. */
  78175. animations: Array<Animation>;
  78176. private _scene;
  78177. private _isDirty;
  78178. private _transformMatrices;
  78179. private _transformMatrixTexture;
  78180. private _meshesWithPoseMatrix;
  78181. private _animatables;
  78182. private _identity;
  78183. private _synchronizedWithMesh;
  78184. private _ranges;
  78185. private _lastAbsoluteTransformsUpdateId;
  78186. private _canUseTextureForBones;
  78187. private _uniqueId;
  78188. /** @hidden */
  78189. _numBonesWithLinkedTransformNode: number;
  78190. /**
  78191. * Specifies if the skeleton should be serialized
  78192. */
  78193. doNotSerialize: boolean;
  78194. private _useTextureToStoreBoneMatrices;
  78195. /**
  78196. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78197. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78198. */
  78199. useTextureToStoreBoneMatrices: boolean;
  78200. private _animationPropertiesOverride;
  78201. /**
  78202. * Gets or sets the animation properties override
  78203. */
  78204. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78205. /**
  78206. * List of inspectable custom properties (used by the Inspector)
  78207. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78208. */
  78209. inspectableCustomProperties: IInspectable[];
  78210. /**
  78211. * An observable triggered before computing the skeleton's matrices
  78212. */
  78213. onBeforeComputeObservable: Observable<Skeleton>;
  78214. /**
  78215. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78216. */
  78217. readonly isUsingTextureForMatrices: boolean;
  78218. /**
  78219. * Gets the unique ID of this skeleton
  78220. */
  78221. readonly uniqueId: number;
  78222. /**
  78223. * Creates a new skeleton
  78224. * @param name defines the skeleton name
  78225. * @param id defines the skeleton Id
  78226. * @param scene defines the hosting scene
  78227. */
  78228. constructor(
  78229. /** defines the skeleton name */
  78230. name: string,
  78231. /** defines the skeleton Id */
  78232. id: string, scene: Scene);
  78233. /**
  78234. * Gets the current object class name.
  78235. * @return the class name
  78236. */
  78237. getClassName(): string;
  78238. /**
  78239. * Returns an array containing the root bones
  78240. * @returns an array containing the root bones
  78241. */
  78242. getChildren(): Array<Bone>;
  78243. /**
  78244. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78245. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78246. * @returns a Float32Array containing matrices data
  78247. */
  78248. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78249. /**
  78250. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78251. * @returns a raw texture containing the data
  78252. */
  78253. getTransformMatrixTexture(): Nullable<RawTexture>;
  78254. /**
  78255. * Gets the current hosting scene
  78256. * @returns a scene object
  78257. */
  78258. getScene(): Scene;
  78259. /**
  78260. * Gets a string representing the current skeleton data
  78261. * @param fullDetails defines a boolean indicating if we want a verbose version
  78262. * @returns a string representing the current skeleton data
  78263. */
  78264. toString(fullDetails?: boolean): string;
  78265. /**
  78266. * Get bone's index searching by name
  78267. * @param name defines bone's name to search for
  78268. * @return the indice of the bone. Returns -1 if not found
  78269. */
  78270. getBoneIndexByName(name: string): number;
  78271. /**
  78272. * Creater a new animation range
  78273. * @param name defines the name of the range
  78274. * @param from defines the start key
  78275. * @param to defines the end key
  78276. */
  78277. createAnimationRange(name: string, from: number, to: number): void;
  78278. /**
  78279. * Delete a specific animation range
  78280. * @param name defines the name of the range
  78281. * @param deleteFrames defines if frames must be removed as well
  78282. */
  78283. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78284. /**
  78285. * Gets a specific animation range
  78286. * @param name defines the name of the range to look for
  78287. * @returns the requested animation range or null if not found
  78288. */
  78289. getAnimationRange(name: string): Nullable<AnimationRange>;
  78290. /**
  78291. * Gets the list of all animation ranges defined on this skeleton
  78292. * @returns an array
  78293. */
  78294. getAnimationRanges(): Nullable<AnimationRange>[];
  78295. /**
  78296. * Copy animation range from a source skeleton.
  78297. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78298. * @param source defines the source skeleton
  78299. * @param name defines the name of the range to copy
  78300. * @param rescaleAsRequired defines if rescaling must be applied if required
  78301. * @returns true if operation was successful
  78302. */
  78303. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78304. /**
  78305. * Forces the skeleton to go to rest pose
  78306. */
  78307. returnToRest(): void;
  78308. private _getHighestAnimationFrame;
  78309. /**
  78310. * Begin a specific animation range
  78311. * @param name defines the name of the range to start
  78312. * @param loop defines if looping must be turned on (false by default)
  78313. * @param speedRatio defines the speed ratio to apply (1 by default)
  78314. * @param onAnimationEnd defines a callback which will be called when animation will end
  78315. * @returns a new animatable
  78316. */
  78317. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78318. /** @hidden */
  78319. _markAsDirty(): void;
  78320. /** @hidden */
  78321. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78322. /** @hidden */
  78323. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78324. private _computeTransformMatrices;
  78325. /**
  78326. * Build all resources required to render a skeleton
  78327. */
  78328. prepare(): void;
  78329. /**
  78330. * Gets the list of animatables currently running for this skeleton
  78331. * @returns an array of animatables
  78332. */
  78333. getAnimatables(): IAnimatable[];
  78334. /**
  78335. * Clone the current skeleton
  78336. * @param name defines the name of the new skeleton
  78337. * @param id defines the id of the new skeleton
  78338. * @returns the new skeleton
  78339. */
  78340. clone(name: string, id: string): Skeleton;
  78341. /**
  78342. * Enable animation blending for this skeleton
  78343. * @param blendingSpeed defines the blending speed to apply
  78344. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78345. */
  78346. enableBlending(blendingSpeed?: number): void;
  78347. /**
  78348. * Releases all resources associated with the current skeleton
  78349. */
  78350. dispose(): void;
  78351. /**
  78352. * Serialize the skeleton in a JSON object
  78353. * @returns a JSON object
  78354. */
  78355. serialize(): any;
  78356. /**
  78357. * Creates a new skeleton from serialized data
  78358. * @param parsedSkeleton defines the serialized data
  78359. * @param scene defines the hosting scene
  78360. * @returns a new skeleton
  78361. */
  78362. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78363. /**
  78364. * Compute all node absolute transforms
  78365. * @param forceUpdate defines if computation must be done even if cache is up to date
  78366. */
  78367. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78368. /**
  78369. * Gets the root pose matrix
  78370. * @returns a matrix
  78371. */
  78372. getPoseMatrix(): Nullable<Matrix>;
  78373. /**
  78374. * Sorts bones per internal index
  78375. */
  78376. sortBones(): void;
  78377. private _sortBones;
  78378. }
  78379. }
  78380. declare module BABYLON {
  78381. /**
  78382. * Defines a target to use with MorphTargetManager
  78383. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78384. */
  78385. export class MorphTarget implements IAnimatable {
  78386. /** defines the name of the target */
  78387. name: string;
  78388. /**
  78389. * Gets or sets the list of animations
  78390. */
  78391. animations: Animation[];
  78392. private _scene;
  78393. private _positions;
  78394. private _normals;
  78395. private _tangents;
  78396. private _influence;
  78397. /**
  78398. * Observable raised when the influence changes
  78399. */
  78400. onInfluenceChanged: Observable<boolean>;
  78401. /** @hidden */
  78402. _onDataLayoutChanged: Observable<void>;
  78403. /**
  78404. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78405. */
  78406. influence: number;
  78407. /**
  78408. * Gets or sets the id of the morph Target
  78409. */
  78410. id: string;
  78411. private _animationPropertiesOverride;
  78412. /**
  78413. * Gets or sets the animation properties override
  78414. */
  78415. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78416. /**
  78417. * Creates a new MorphTarget
  78418. * @param name defines the name of the target
  78419. * @param influence defines the influence to use
  78420. * @param scene defines the scene the morphtarget belongs to
  78421. */
  78422. constructor(
  78423. /** defines the name of the target */
  78424. name: string, influence?: number, scene?: Nullable<Scene>);
  78425. /**
  78426. * Gets a boolean defining if the target contains position data
  78427. */
  78428. readonly hasPositions: boolean;
  78429. /**
  78430. * Gets a boolean defining if the target contains normal data
  78431. */
  78432. readonly hasNormals: boolean;
  78433. /**
  78434. * Gets a boolean defining if the target contains tangent data
  78435. */
  78436. readonly hasTangents: boolean;
  78437. /**
  78438. * Affects position data to this target
  78439. * @param data defines the position data to use
  78440. */
  78441. setPositions(data: Nullable<FloatArray>): void;
  78442. /**
  78443. * Gets the position data stored in this target
  78444. * @returns a FloatArray containing the position data (or null if not present)
  78445. */
  78446. getPositions(): Nullable<FloatArray>;
  78447. /**
  78448. * Affects normal data to this target
  78449. * @param data defines the normal data to use
  78450. */
  78451. setNormals(data: Nullable<FloatArray>): void;
  78452. /**
  78453. * Gets the normal data stored in this target
  78454. * @returns a FloatArray containing the normal data (or null if not present)
  78455. */
  78456. getNormals(): Nullable<FloatArray>;
  78457. /**
  78458. * Affects tangent data to this target
  78459. * @param data defines the tangent data to use
  78460. */
  78461. setTangents(data: Nullable<FloatArray>): void;
  78462. /**
  78463. * Gets the tangent data stored in this target
  78464. * @returns a FloatArray containing the tangent data (or null if not present)
  78465. */
  78466. getTangents(): Nullable<FloatArray>;
  78467. /**
  78468. * Serializes the current target into a Serialization object
  78469. * @returns the serialized object
  78470. */
  78471. serialize(): any;
  78472. /**
  78473. * Returns the string "MorphTarget"
  78474. * @returns "MorphTarget"
  78475. */
  78476. getClassName(): string;
  78477. /**
  78478. * Creates a new target from serialized data
  78479. * @param serializationObject defines the serialized data to use
  78480. * @returns a new MorphTarget
  78481. */
  78482. static Parse(serializationObject: any): MorphTarget;
  78483. /**
  78484. * Creates a MorphTarget from mesh data
  78485. * @param mesh defines the source mesh
  78486. * @param name defines the name to use for the new target
  78487. * @param influence defines the influence to attach to the target
  78488. * @returns a new MorphTarget
  78489. */
  78490. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78491. }
  78492. }
  78493. declare module BABYLON {
  78494. /**
  78495. * This class is used to deform meshes using morphing between different targets
  78496. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78497. */
  78498. export class MorphTargetManager {
  78499. private _targets;
  78500. private _targetInfluenceChangedObservers;
  78501. private _targetDataLayoutChangedObservers;
  78502. private _activeTargets;
  78503. private _scene;
  78504. private _influences;
  78505. private _supportsNormals;
  78506. private _supportsTangents;
  78507. private _vertexCount;
  78508. private _uniqueId;
  78509. private _tempInfluences;
  78510. /**
  78511. * Creates a new MorphTargetManager
  78512. * @param scene defines the current scene
  78513. */
  78514. constructor(scene?: Nullable<Scene>);
  78515. /**
  78516. * Gets the unique ID of this manager
  78517. */
  78518. readonly uniqueId: number;
  78519. /**
  78520. * Gets the number of vertices handled by this manager
  78521. */
  78522. readonly vertexCount: number;
  78523. /**
  78524. * Gets a boolean indicating if this manager supports morphing of normals
  78525. */
  78526. readonly supportsNormals: boolean;
  78527. /**
  78528. * Gets a boolean indicating if this manager supports morphing of tangents
  78529. */
  78530. readonly supportsTangents: boolean;
  78531. /**
  78532. * Gets the number of targets stored in this manager
  78533. */
  78534. readonly numTargets: number;
  78535. /**
  78536. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78537. */
  78538. readonly numInfluencers: number;
  78539. /**
  78540. * Gets the list of influences (one per target)
  78541. */
  78542. readonly influences: Float32Array;
  78543. /**
  78544. * Gets the active target at specified index. An active target is a target with an influence > 0
  78545. * @param index defines the index to check
  78546. * @returns the requested target
  78547. */
  78548. getActiveTarget(index: number): MorphTarget;
  78549. /**
  78550. * Gets the target at specified index
  78551. * @param index defines the index to check
  78552. * @returns the requested target
  78553. */
  78554. getTarget(index: number): MorphTarget;
  78555. /**
  78556. * Add a new target to this manager
  78557. * @param target defines the target to add
  78558. */
  78559. addTarget(target: MorphTarget): void;
  78560. /**
  78561. * Removes a target from the manager
  78562. * @param target defines the target to remove
  78563. */
  78564. removeTarget(target: MorphTarget): void;
  78565. /**
  78566. * Serializes the current manager into a Serialization object
  78567. * @returns the serialized object
  78568. */
  78569. serialize(): any;
  78570. private _syncActiveTargets;
  78571. /**
  78572. * Syncrhonize the targets with all the meshes using this morph target manager
  78573. */
  78574. synchronize(): void;
  78575. /**
  78576. * Creates a new MorphTargetManager from serialized data
  78577. * @param serializationObject defines the serialized data
  78578. * @param scene defines the hosting scene
  78579. * @returns the new MorphTargetManager
  78580. */
  78581. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78582. }
  78583. }
  78584. declare module BABYLON {
  78585. /**
  78586. * Mesh representing the gorund
  78587. */
  78588. export class GroundMesh extends Mesh {
  78589. /** If octree should be generated */
  78590. generateOctree: boolean;
  78591. private _heightQuads;
  78592. /** @hidden */
  78593. _subdivisionsX: number;
  78594. /** @hidden */
  78595. _subdivisionsY: number;
  78596. /** @hidden */
  78597. _width: number;
  78598. /** @hidden */
  78599. _height: number;
  78600. /** @hidden */
  78601. _minX: number;
  78602. /** @hidden */
  78603. _maxX: number;
  78604. /** @hidden */
  78605. _minZ: number;
  78606. /** @hidden */
  78607. _maxZ: number;
  78608. constructor(name: string, scene: Scene);
  78609. /**
  78610. * "GroundMesh"
  78611. * @returns "GroundMesh"
  78612. */
  78613. getClassName(): string;
  78614. /**
  78615. * The minimum of x and y subdivisions
  78616. */
  78617. readonly subdivisions: number;
  78618. /**
  78619. * X subdivisions
  78620. */
  78621. readonly subdivisionsX: number;
  78622. /**
  78623. * Y subdivisions
  78624. */
  78625. readonly subdivisionsY: number;
  78626. /**
  78627. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78628. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78629. * @param chunksCount the number of subdivisions for x and y
  78630. * @param octreeBlocksSize (Default: 32)
  78631. */
  78632. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78633. /**
  78634. * Returns a height (y) value in the Worl system :
  78635. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78636. * @param x x coordinate
  78637. * @param z z coordinate
  78638. * @returns the ground y position if (x, z) are outside the ground surface.
  78639. */
  78640. getHeightAtCoordinates(x: number, z: number): number;
  78641. /**
  78642. * Returns a normalized vector (Vector3) orthogonal to the ground
  78643. * at the ground coordinates (x, z) expressed in the World system.
  78644. * @param x x coordinate
  78645. * @param z z coordinate
  78646. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78647. */
  78648. getNormalAtCoordinates(x: number, z: number): Vector3;
  78649. /**
  78650. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78651. * at the ground coordinates (x, z) expressed in the World system.
  78652. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78653. * @param x x coordinate
  78654. * @param z z coordinate
  78655. * @param ref vector to store the result
  78656. * @returns the GroundMesh.
  78657. */
  78658. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78659. /**
  78660. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78661. * if the ground has been updated.
  78662. * This can be used in the render loop.
  78663. * @returns the GroundMesh.
  78664. */
  78665. updateCoordinateHeights(): GroundMesh;
  78666. private _getFacetAt;
  78667. private _initHeightQuads;
  78668. private _computeHeightQuads;
  78669. /**
  78670. * Serializes this ground mesh
  78671. * @param serializationObject object to write serialization to
  78672. */
  78673. serialize(serializationObject: any): void;
  78674. /**
  78675. * Parses a serialized ground mesh
  78676. * @param parsedMesh the serialized mesh
  78677. * @param scene the scene to create the ground mesh in
  78678. * @returns the created ground mesh
  78679. */
  78680. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78681. }
  78682. }
  78683. declare module BABYLON {
  78684. /**
  78685. * Interface for Physics-Joint data
  78686. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78687. */
  78688. export interface PhysicsJointData {
  78689. /**
  78690. * The main pivot of the joint
  78691. */
  78692. mainPivot?: Vector3;
  78693. /**
  78694. * The connected pivot of the joint
  78695. */
  78696. connectedPivot?: Vector3;
  78697. /**
  78698. * The main axis of the joint
  78699. */
  78700. mainAxis?: Vector3;
  78701. /**
  78702. * The connected axis of the joint
  78703. */
  78704. connectedAxis?: Vector3;
  78705. /**
  78706. * The collision of the joint
  78707. */
  78708. collision?: boolean;
  78709. /**
  78710. * Native Oimo/Cannon/Energy data
  78711. */
  78712. nativeParams?: any;
  78713. }
  78714. /**
  78715. * This is a holder class for the physics joint created by the physics plugin
  78716. * It holds a set of functions to control the underlying joint
  78717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78718. */
  78719. export class PhysicsJoint {
  78720. /**
  78721. * The type of the physics joint
  78722. */
  78723. type: number;
  78724. /**
  78725. * The data for the physics joint
  78726. */
  78727. jointData: PhysicsJointData;
  78728. private _physicsJoint;
  78729. protected _physicsPlugin: IPhysicsEnginePlugin;
  78730. /**
  78731. * Initializes the physics joint
  78732. * @param type The type of the physics joint
  78733. * @param jointData The data for the physics joint
  78734. */
  78735. constructor(
  78736. /**
  78737. * The type of the physics joint
  78738. */
  78739. type: number,
  78740. /**
  78741. * The data for the physics joint
  78742. */
  78743. jointData: PhysicsJointData);
  78744. /**
  78745. * Gets the physics joint
  78746. */
  78747. /**
  78748. * Sets the physics joint
  78749. */
  78750. physicsJoint: any;
  78751. /**
  78752. * Sets the physics plugin
  78753. */
  78754. physicsPlugin: IPhysicsEnginePlugin;
  78755. /**
  78756. * Execute a function that is physics-plugin specific.
  78757. * @param {Function} func the function that will be executed.
  78758. * It accepts two parameters: the physics world and the physics joint
  78759. */
  78760. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  78761. /**
  78762. * Distance-Joint type
  78763. */
  78764. static DistanceJoint: number;
  78765. /**
  78766. * Hinge-Joint type
  78767. */
  78768. static HingeJoint: number;
  78769. /**
  78770. * Ball-and-Socket joint type
  78771. */
  78772. static BallAndSocketJoint: number;
  78773. /**
  78774. * Wheel-Joint type
  78775. */
  78776. static WheelJoint: number;
  78777. /**
  78778. * Slider-Joint type
  78779. */
  78780. static SliderJoint: number;
  78781. /**
  78782. * Prismatic-Joint type
  78783. */
  78784. static PrismaticJoint: number;
  78785. /**
  78786. * Universal-Joint type
  78787. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  78788. */
  78789. static UniversalJoint: number;
  78790. /**
  78791. * Hinge-Joint 2 type
  78792. */
  78793. static Hinge2Joint: number;
  78794. /**
  78795. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  78796. */
  78797. static PointToPointJoint: number;
  78798. /**
  78799. * Spring-Joint type
  78800. */
  78801. static SpringJoint: number;
  78802. /**
  78803. * Lock-Joint type
  78804. */
  78805. static LockJoint: number;
  78806. }
  78807. /**
  78808. * A class representing a physics distance joint
  78809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78810. */
  78811. export class DistanceJoint extends PhysicsJoint {
  78812. /**
  78813. *
  78814. * @param jointData The data for the Distance-Joint
  78815. */
  78816. constructor(jointData: DistanceJointData);
  78817. /**
  78818. * Update the predefined distance.
  78819. * @param maxDistance The maximum preferred distance
  78820. * @param minDistance The minimum preferred distance
  78821. */
  78822. updateDistance(maxDistance: number, minDistance?: number): void;
  78823. }
  78824. /**
  78825. * Represents a Motor-Enabled Joint
  78826. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78827. */
  78828. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  78829. /**
  78830. * Initializes the Motor-Enabled Joint
  78831. * @param type The type of the joint
  78832. * @param jointData The physica joint data for the joint
  78833. */
  78834. constructor(type: number, jointData: PhysicsJointData);
  78835. /**
  78836. * Set the motor values.
  78837. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78838. * @param force the force to apply
  78839. * @param maxForce max force for this motor.
  78840. */
  78841. setMotor(force?: number, maxForce?: number): void;
  78842. /**
  78843. * Set the motor's limits.
  78844. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78845. * @param upperLimit The upper limit of the motor
  78846. * @param lowerLimit The lower limit of the motor
  78847. */
  78848. setLimit(upperLimit: number, lowerLimit?: number): void;
  78849. }
  78850. /**
  78851. * This class represents a single physics Hinge-Joint
  78852. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78853. */
  78854. export class HingeJoint extends MotorEnabledJoint {
  78855. /**
  78856. * Initializes the Hinge-Joint
  78857. * @param jointData The joint data for the Hinge-Joint
  78858. */
  78859. constructor(jointData: PhysicsJointData);
  78860. /**
  78861. * Set the motor values.
  78862. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78863. * @param {number} force the force to apply
  78864. * @param {number} maxForce max force for this motor.
  78865. */
  78866. setMotor(force?: number, maxForce?: number): void;
  78867. /**
  78868. * Set the motor's limits.
  78869. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78870. * @param upperLimit The upper limit of the motor
  78871. * @param lowerLimit The lower limit of the motor
  78872. */
  78873. setLimit(upperLimit: number, lowerLimit?: number): void;
  78874. }
  78875. /**
  78876. * This class represents a dual hinge physics joint (same as wheel joint)
  78877. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78878. */
  78879. export class Hinge2Joint extends MotorEnabledJoint {
  78880. /**
  78881. * Initializes the Hinge2-Joint
  78882. * @param jointData The joint data for the Hinge2-Joint
  78883. */
  78884. constructor(jointData: PhysicsJointData);
  78885. /**
  78886. * Set the motor values.
  78887. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78888. * @param {number} targetSpeed the speed the motor is to reach
  78889. * @param {number} maxForce max force for this motor.
  78890. * @param {motorIndex} the motor's index, 0 or 1.
  78891. */
  78892. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  78893. /**
  78894. * Set the motor limits.
  78895. * Attention, this function is plugin specific. Engines won't react 100% the same.
  78896. * @param {number} upperLimit the upper limit
  78897. * @param {number} lowerLimit lower limit
  78898. * @param {motorIndex} the motor's index, 0 or 1.
  78899. */
  78900. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78901. }
  78902. /**
  78903. * Interface for a motor enabled joint
  78904. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78905. */
  78906. export interface IMotorEnabledJoint {
  78907. /**
  78908. * Physics joint
  78909. */
  78910. physicsJoint: any;
  78911. /**
  78912. * Sets the motor of the motor-enabled joint
  78913. * @param force The force of the motor
  78914. * @param maxForce The maximum force of the motor
  78915. * @param motorIndex The index of the motor
  78916. */
  78917. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  78918. /**
  78919. * Sets the limit of the motor
  78920. * @param upperLimit The upper limit of the motor
  78921. * @param lowerLimit The lower limit of the motor
  78922. * @param motorIndex The index of the motor
  78923. */
  78924. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  78925. }
  78926. /**
  78927. * Joint data for a Distance-Joint
  78928. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78929. */
  78930. export interface DistanceJointData extends PhysicsJointData {
  78931. /**
  78932. * Max distance the 2 joint objects can be apart
  78933. */
  78934. maxDistance: number;
  78935. }
  78936. /**
  78937. * Joint data from a spring joint
  78938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78939. */
  78940. export interface SpringJointData extends PhysicsJointData {
  78941. /**
  78942. * Length of the spring
  78943. */
  78944. length: number;
  78945. /**
  78946. * Stiffness of the spring
  78947. */
  78948. stiffness: number;
  78949. /**
  78950. * Damping of the spring
  78951. */
  78952. damping: number;
  78953. /** this callback will be called when applying the force to the impostors. */
  78954. forceApplicationCallback: () => void;
  78955. }
  78956. }
  78957. declare module BABYLON {
  78958. /**
  78959. * Holds the data for the raycast result
  78960. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78961. */
  78962. export class PhysicsRaycastResult {
  78963. private _hasHit;
  78964. private _hitDistance;
  78965. private _hitNormalWorld;
  78966. private _hitPointWorld;
  78967. private _rayFromWorld;
  78968. private _rayToWorld;
  78969. /**
  78970. * Gets if there was a hit
  78971. */
  78972. readonly hasHit: boolean;
  78973. /**
  78974. * Gets the distance from the hit
  78975. */
  78976. readonly hitDistance: number;
  78977. /**
  78978. * Gets the hit normal/direction in the world
  78979. */
  78980. readonly hitNormalWorld: Vector3;
  78981. /**
  78982. * Gets the hit point in the world
  78983. */
  78984. readonly hitPointWorld: Vector3;
  78985. /**
  78986. * Gets the ray "start point" of the ray in the world
  78987. */
  78988. readonly rayFromWorld: Vector3;
  78989. /**
  78990. * Gets the ray "end point" of the ray in the world
  78991. */
  78992. readonly rayToWorld: Vector3;
  78993. /**
  78994. * Sets the hit data (normal & point in world space)
  78995. * @param hitNormalWorld defines the normal in world space
  78996. * @param hitPointWorld defines the point in world space
  78997. */
  78998. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  78999. /**
  79000. * Sets the distance from the start point to the hit point
  79001. * @param distance
  79002. */
  79003. setHitDistance(distance: number): void;
  79004. /**
  79005. * Calculates the distance manually
  79006. */
  79007. calculateHitDistance(): void;
  79008. /**
  79009. * Resets all the values to default
  79010. * @param from The from point on world space
  79011. * @param to The to point on world space
  79012. */
  79013. reset(from?: Vector3, to?: Vector3): void;
  79014. }
  79015. /**
  79016. * Interface for the size containing width and height
  79017. */
  79018. interface IXYZ {
  79019. /**
  79020. * X
  79021. */
  79022. x: number;
  79023. /**
  79024. * Y
  79025. */
  79026. y: number;
  79027. /**
  79028. * Z
  79029. */
  79030. z: number;
  79031. }
  79032. }
  79033. declare module BABYLON {
  79034. /**
  79035. * Interface used to describe a physics joint
  79036. */
  79037. export interface PhysicsImpostorJoint {
  79038. /** Defines the main impostor to which the joint is linked */
  79039. mainImpostor: PhysicsImpostor;
  79040. /** Defines the impostor that is connected to the main impostor using this joint */
  79041. connectedImpostor: PhysicsImpostor;
  79042. /** Defines the joint itself */
  79043. joint: PhysicsJoint;
  79044. }
  79045. /** @hidden */
  79046. export interface IPhysicsEnginePlugin {
  79047. world: any;
  79048. name: string;
  79049. setGravity(gravity: Vector3): void;
  79050. setTimeStep(timeStep: number): void;
  79051. getTimeStep(): number;
  79052. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79053. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79054. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79055. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79056. removePhysicsBody(impostor: PhysicsImpostor): void;
  79057. generateJoint(joint: PhysicsImpostorJoint): void;
  79058. removeJoint(joint: PhysicsImpostorJoint): void;
  79059. isSupported(): boolean;
  79060. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79061. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79062. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79063. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79064. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79065. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79066. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79067. getBodyMass(impostor: PhysicsImpostor): number;
  79068. getBodyFriction(impostor: PhysicsImpostor): number;
  79069. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79070. getBodyRestitution(impostor: PhysicsImpostor): number;
  79071. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79072. getBodyPressure?(impostor: PhysicsImpostor): number;
  79073. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79074. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79075. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79076. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79077. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79078. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79079. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79080. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79081. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79082. sleepBody(impostor: PhysicsImpostor): void;
  79083. wakeUpBody(impostor: PhysicsImpostor): void;
  79084. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79085. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79086. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79087. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79088. getRadius(impostor: PhysicsImpostor): number;
  79089. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79090. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79091. dispose(): void;
  79092. }
  79093. /**
  79094. * Interface used to define a physics engine
  79095. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79096. */
  79097. export interface IPhysicsEngine {
  79098. /**
  79099. * Gets the gravity vector used by the simulation
  79100. */
  79101. gravity: Vector3;
  79102. /**
  79103. * Sets the gravity vector used by the simulation
  79104. * @param gravity defines the gravity vector to use
  79105. */
  79106. setGravity(gravity: Vector3): void;
  79107. /**
  79108. * Set the time step of the physics engine.
  79109. * Default is 1/60.
  79110. * To slow it down, enter 1/600 for example.
  79111. * To speed it up, 1/30
  79112. * @param newTimeStep the new timestep to apply to this world.
  79113. */
  79114. setTimeStep(newTimeStep: number): void;
  79115. /**
  79116. * Get the time step of the physics engine.
  79117. * @returns the current time step
  79118. */
  79119. getTimeStep(): number;
  79120. /**
  79121. * Release all resources
  79122. */
  79123. dispose(): void;
  79124. /**
  79125. * Gets the name of the current physics plugin
  79126. * @returns the name of the plugin
  79127. */
  79128. getPhysicsPluginName(): string;
  79129. /**
  79130. * Adding a new impostor for the impostor tracking.
  79131. * This will be done by the impostor itself.
  79132. * @param impostor the impostor to add
  79133. */
  79134. addImpostor(impostor: PhysicsImpostor): void;
  79135. /**
  79136. * Remove an impostor from the engine.
  79137. * This impostor and its mesh will not longer be updated by the physics engine.
  79138. * @param impostor the impostor to remove
  79139. */
  79140. removeImpostor(impostor: PhysicsImpostor): void;
  79141. /**
  79142. * Add a joint to the physics engine
  79143. * @param mainImpostor defines the main impostor to which the joint is added.
  79144. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79145. * @param joint defines the joint that will connect both impostors.
  79146. */
  79147. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79148. /**
  79149. * Removes a joint from the simulation
  79150. * @param mainImpostor defines the impostor used with the joint
  79151. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79152. * @param joint defines the joint to remove
  79153. */
  79154. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79155. /**
  79156. * Gets the current plugin used to run the simulation
  79157. * @returns current plugin
  79158. */
  79159. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79160. /**
  79161. * Gets the list of physic impostors
  79162. * @returns an array of PhysicsImpostor
  79163. */
  79164. getImpostors(): Array<PhysicsImpostor>;
  79165. /**
  79166. * Gets the impostor for a physics enabled object
  79167. * @param object defines the object impersonated by the impostor
  79168. * @returns the PhysicsImpostor or null if not found
  79169. */
  79170. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79171. /**
  79172. * Gets the impostor for a physics body object
  79173. * @param body defines physics body used by the impostor
  79174. * @returns the PhysicsImpostor or null if not found
  79175. */
  79176. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79177. /**
  79178. * Does a raycast in the physics world
  79179. * @param from when should the ray start?
  79180. * @param to when should the ray end?
  79181. * @returns PhysicsRaycastResult
  79182. */
  79183. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79184. /**
  79185. * Called by the scene. No need to call it.
  79186. * @param delta defines the timespam between frames
  79187. */
  79188. _step(delta: number): void;
  79189. }
  79190. }
  79191. declare module BABYLON {
  79192. /**
  79193. * The interface for the physics imposter parameters
  79194. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79195. */
  79196. export interface PhysicsImpostorParameters {
  79197. /**
  79198. * The mass of the physics imposter
  79199. */
  79200. mass: number;
  79201. /**
  79202. * The friction of the physics imposter
  79203. */
  79204. friction?: number;
  79205. /**
  79206. * The coefficient of restitution of the physics imposter
  79207. */
  79208. restitution?: number;
  79209. /**
  79210. * The native options of the physics imposter
  79211. */
  79212. nativeOptions?: any;
  79213. /**
  79214. * Specifies if the parent should be ignored
  79215. */
  79216. ignoreParent?: boolean;
  79217. /**
  79218. * Specifies if bi-directional transformations should be disabled
  79219. */
  79220. disableBidirectionalTransformation?: boolean;
  79221. /**
  79222. * The pressure inside the physics imposter, soft object only
  79223. */
  79224. pressure?: number;
  79225. /**
  79226. * The stiffness the physics imposter, soft object only
  79227. */
  79228. stiffness?: number;
  79229. /**
  79230. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79231. */
  79232. velocityIterations?: number;
  79233. /**
  79234. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79235. */
  79236. positionIterations?: number;
  79237. /**
  79238. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79239. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79240. * Add to fix multiple points
  79241. */
  79242. fixedPoints?: number;
  79243. /**
  79244. * The collision margin around a soft object
  79245. */
  79246. margin?: number;
  79247. /**
  79248. * The collision margin around a soft object
  79249. */
  79250. damping?: number;
  79251. /**
  79252. * The path for a rope based on an extrusion
  79253. */
  79254. path?: any;
  79255. /**
  79256. * The shape of an extrusion used for a rope based on an extrusion
  79257. */
  79258. shape?: any;
  79259. }
  79260. /**
  79261. * Interface for a physics-enabled object
  79262. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79263. */
  79264. export interface IPhysicsEnabledObject {
  79265. /**
  79266. * The position of the physics-enabled object
  79267. */
  79268. position: Vector3;
  79269. /**
  79270. * The rotation of the physics-enabled object
  79271. */
  79272. rotationQuaternion: Nullable<Quaternion>;
  79273. /**
  79274. * The scale of the physics-enabled object
  79275. */
  79276. scaling: Vector3;
  79277. /**
  79278. * The rotation of the physics-enabled object
  79279. */
  79280. rotation?: Vector3;
  79281. /**
  79282. * The parent of the physics-enabled object
  79283. */
  79284. parent?: any;
  79285. /**
  79286. * The bounding info of the physics-enabled object
  79287. * @returns The bounding info of the physics-enabled object
  79288. */
  79289. getBoundingInfo(): BoundingInfo;
  79290. /**
  79291. * Computes the world matrix
  79292. * @param force Specifies if the world matrix should be computed by force
  79293. * @returns A world matrix
  79294. */
  79295. computeWorldMatrix(force: boolean): Matrix;
  79296. /**
  79297. * Gets the world matrix
  79298. * @returns A world matrix
  79299. */
  79300. getWorldMatrix?(): Matrix;
  79301. /**
  79302. * Gets the child meshes
  79303. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79304. * @returns An array of abstract meshes
  79305. */
  79306. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79307. /**
  79308. * Gets the vertex data
  79309. * @param kind The type of vertex data
  79310. * @returns A nullable array of numbers, or a float32 array
  79311. */
  79312. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79313. /**
  79314. * Gets the indices from the mesh
  79315. * @returns A nullable array of index arrays
  79316. */
  79317. getIndices?(): Nullable<IndicesArray>;
  79318. /**
  79319. * Gets the scene from the mesh
  79320. * @returns the indices array or null
  79321. */
  79322. getScene?(): Scene;
  79323. /**
  79324. * Gets the absolute position from the mesh
  79325. * @returns the absolute position
  79326. */
  79327. getAbsolutePosition(): Vector3;
  79328. /**
  79329. * Gets the absolute pivot point from the mesh
  79330. * @returns the absolute pivot point
  79331. */
  79332. getAbsolutePivotPoint(): Vector3;
  79333. /**
  79334. * Rotates the mesh
  79335. * @param axis The axis of rotation
  79336. * @param amount The amount of rotation
  79337. * @param space The space of the rotation
  79338. * @returns The rotation transform node
  79339. */
  79340. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79341. /**
  79342. * Translates the mesh
  79343. * @param axis The axis of translation
  79344. * @param distance The distance of translation
  79345. * @param space The space of the translation
  79346. * @returns The transform node
  79347. */
  79348. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79349. /**
  79350. * Sets the absolute position of the mesh
  79351. * @param absolutePosition The absolute position of the mesh
  79352. * @returns The transform node
  79353. */
  79354. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79355. /**
  79356. * Gets the class name of the mesh
  79357. * @returns The class name
  79358. */
  79359. getClassName(): string;
  79360. }
  79361. /**
  79362. * Represents a physics imposter
  79363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79364. */
  79365. export class PhysicsImpostor {
  79366. /**
  79367. * The physics-enabled object used as the physics imposter
  79368. */
  79369. object: IPhysicsEnabledObject;
  79370. /**
  79371. * The type of the physics imposter
  79372. */
  79373. type: number;
  79374. private _options;
  79375. private _scene?;
  79376. /**
  79377. * The default object size of the imposter
  79378. */
  79379. static DEFAULT_OBJECT_SIZE: Vector3;
  79380. /**
  79381. * The identity quaternion of the imposter
  79382. */
  79383. static IDENTITY_QUATERNION: Quaternion;
  79384. /** @hidden */
  79385. _pluginData: any;
  79386. private _physicsEngine;
  79387. private _physicsBody;
  79388. private _bodyUpdateRequired;
  79389. private _onBeforePhysicsStepCallbacks;
  79390. private _onAfterPhysicsStepCallbacks;
  79391. /** @hidden */
  79392. _onPhysicsCollideCallbacks: Array<{
  79393. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79394. otherImpostors: Array<PhysicsImpostor>;
  79395. }>;
  79396. private _deltaPosition;
  79397. private _deltaRotation;
  79398. private _deltaRotationConjugated;
  79399. /** hidden */
  79400. _isFromLine: boolean;
  79401. private _parent;
  79402. private _isDisposed;
  79403. private static _tmpVecs;
  79404. private static _tmpQuat;
  79405. /**
  79406. * Specifies if the physics imposter is disposed
  79407. */
  79408. readonly isDisposed: boolean;
  79409. /**
  79410. * Gets the mass of the physics imposter
  79411. */
  79412. mass: number;
  79413. /**
  79414. * Gets the coefficient of friction
  79415. */
  79416. /**
  79417. * Sets the coefficient of friction
  79418. */
  79419. friction: number;
  79420. /**
  79421. * Gets the coefficient of restitution
  79422. */
  79423. /**
  79424. * Sets the coefficient of restitution
  79425. */
  79426. restitution: number;
  79427. /**
  79428. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79429. */
  79430. /**
  79431. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79432. */
  79433. pressure: number;
  79434. /**
  79435. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79436. */
  79437. /**
  79438. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79439. */
  79440. stiffness: number;
  79441. /**
  79442. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79443. */
  79444. /**
  79445. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79446. */
  79447. velocityIterations: number;
  79448. /**
  79449. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79450. */
  79451. /**
  79452. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79453. */
  79454. positionIterations: number;
  79455. /**
  79456. * The unique id of the physics imposter
  79457. * set by the physics engine when adding this impostor to the array
  79458. */
  79459. uniqueId: number;
  79460. /**
  79461. * @hidden
  79462. */
  79463. soft: boolean;
  79464. /**
  79465. * @hidden
  79466. */
  79467. segments: number;
  79468. private _joints;
  79469. /**
  79470. * Initializes the physics imposter
  79471. * @param object The physics-enabled object used as the physics imposter
  79472. * @param type The type of the physics imposter
  79473. * @param _options The options for the physics imposter
  79474. * @param _scene The Babylon scene
  79475. */
  79476. constructor(
  79477. /**
  79478. * The physics-enabled object used as the physics imposter
  79479. */
  79480. object: IPhysicsEnabledObject,
  79481. /**
  79482. * The type of the physics imposter
  79483. */
  79484. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79485. /**
  79486. * This function will completly initialize this impostor.
  79487. * It will create a new body - but only if this mesh has no parent.
  79488. * If it has, this impostor will not be used other than to define the impostor
  79489. * of the child mesh.
  79490. * @hidden
  79491. */
  79492. _init(): void;
  79493. private _getPhysicsParent;
  79494. /**
  79495. * Should a new body be generated.
  79496. * @returns boolean specifying if body initialization is required
  79497. */
  79498. isBodyInitRequired(): boolean;
  79499. /**
  79500. * Sets the updated scaling
  79501. * @param updated Specifies if the scaling is updated
  79502. */
  79503. setScalingUpdated(): void;
  79504. /**
  79505. * Force a regeneration of this or the parent's impostor's body.
  79506. * Use under cautious - This will remove all joints already implemented.
  79507. */
  79508. forceUpdate(): void;
  79509. /**
  79510. * Gets the body that holds this impostor. Either its own, or its parent.
  79511. */
  79512. /**
  79513. * Set the physics body. Used mainly by the physics engine/plugin
  79514. */
  79515. physicsBody: any;
  79516. /**
  79517. * Get the parent of the physics imposter
  79518. * @returns Physics imposter or null
  79519. */
  79520. /**
  79521. * Sets the parent of the physics imposter
  79522. */
  79523. parent: Nullable<PhysicsImpostor>;
  79524. /**
  79525. * Resets the update flags
  79526. */
  79527. resetUpdateFlags(): void;
  79528. /**
  79529. * Gets the object extend size
  79530. * @returns the object extend size
  79531. */
  79532. getObjectExtendSize(): Vector3;
  79533. /**
  79534. * Gets the object center
  79535. * @returns The object center
  79536. */
  79537. getObjectCenter(): Vector3;
  79538. /**
  79539. * Get a specific parametes from the options parameter
  79540. * @param paramName The object parameter name
  79541. * @returns The object parameter
  79542. */
  79543. getParam(paramName: string): any;
  79544. /**
  79545. * Sets a specific parameter in the options given to the physics plugin
  79546. * @param paramName The parameter name
  79547. * @param value The value of the parameter
  79548. */
  79549. setParam(paramName: string, value: number): void;
  79550. /**
  79551. * Specifically change the body's mass option. Won't recreate the physics body object
  79552. * @param mass The mass of the physics imposter
  79553. */
  79554. setMass(mass: number): void;
  79555. /**
  79556. * Gets the linear velocity
  79557. * @returns linear velocity or null
  79558. */
  79559. getLinearVelocity(): Nullable<Vector3>;
  79560. /**
  79561. * Sets the linear velocity
  79562. * @param velocity linear velocity or null
  79563. */
  79564. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79565. /**
  79566. * Gets the angular velocity
  79567. * @returns angular velocity or null
  79568. */
  79569. getAngularVelocity(): Nullable<Vector3>;
  79570. /**
  79571. * Sets the angular velocity
  79572. * @param velocity The velocity or null
  79573. */
  79574. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79575. /**
  79576. * Execute a function with the physics plugin native code
  79577. * Provide a function the will have two variables - the world object and the physics body object
  79578. * @param func The function to execute with the physics plugin native code
  79579. */
  79580. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79581. /**
  79582. * Register a function that will be executed before the physics world is stepping forward
  79583. * @param func The function to execute before the physics world is stepped forward
  79584. */
  79585. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79586. /**
  79587. * Unregister a function that will be executed before the physics world is stepping forward
  79588. * @param func The function to execute before the physics world is stepped forward
  79589. */
  79590. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79591. /**
  79592. * Register a function that will be executed after the physics step
  79593. * @param func The function to execute after physics step
  79594. */
  79595. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79596. /**
  79597. * Unregisters a function that will be executed after the physics step
  79598. * @param func The function to execute after physics step
  79599. */
  79600. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79601. /**
  79602. * register a function that will be executed when this impostor collides against a different body
  79603. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79604. * @param func Callback that is executed on collision
  79605. */
  79606. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79607. /**
  79608. * Unregisters the physics imposter on contact
  79609. * @param collideAgainst The physics object to collide against
  79610. * @param func Callback to execute on collision
  79611. */
  79612. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79613. private _tmpQuat;
  79614. private _tmpQuat2;
  79615. /**
  79616. * Get the parent rotation
  79617. * @returns The parent rotation
  79618. */
  79619. getParentsRotation(): Quaternion;
  79620. /**
  79621. * this function is executed by the physics engine.
  79622. */
  79623. beforeStep: () => void;
  79624. /**
  79625. * this function is executed by the physics engine
  79626. */
  79627. afterStep: () => void;
  79628. /**
  79629. * Legacy collision detection event support
  79630. */
  79631. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79632. /**
  79633. * event and body object due to cannon's event-based architecture.
  79634. */
  79635. onCollide: (e: {
  79636. body: any;
  79637. }) => void;
  79638. /**
  79639. * Apply a force
  79640. * @param force The force to apply
  79641. * @param contactPoint The contact point for the force
  79642. * @returns The physics imposter
  79643. */
  79644. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79645. /**
  79646. * Apply an impulse
  79647. * @param force The impulse force
  79648. * @param contactPoint The contact point for the impulse force
  79649. * @returns The physics imposter
  79650. */
  79651. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79652. /**
  79653. * A help function to create a joint
  79654. * @param otherImpostor A physics imposter used to create a joint
  79655. * @param jointType The type of joint
  79656. * @param jointData The data for the joint
  79657. * @returns The physics imposter
  79658. */
  79659. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79660. /**
  79661. * Add a joint to this impostor with a different impostor
  79662. * @param otherImpostor A physics imposter used to add a joint
  79663. * @param joint The joint to add
  79664. * @returns The physics imposter
  79665. */
  79666. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79667. /**
  79668. * Add an anchor to a cloth impostor
  79669. * @param otherImpostor rigid impostor to anchor to
  79670. * @param width ratio across width from 0 to 1
  79671. * @param height ratio up height from 0 to 1
  79672. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79673. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79674. * @returns impostor the soft imposter
  79675. */
  79676. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79677. /**
  79678. * Add a hook to a rope impostor
  79679. * @param otherImpostor rigid impostor to anchor to
  79680. * @param length ratio across rope from 0 to 1
  79681. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79682. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79683. * @returns impostor the rope imposter
  79684. */
  79685. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79686. /**
  79687. * Will keep this body still, in a sleep mode.
  79688. * @returns the physics imposter
  79689. */
  79690. sleep(): PhysicsImpostor;
  79691. /**
  79692. * Wake the body up.
  79693. * @returns The physics imposter
  79694. */
  79695. wakeUp(): PhysicsImpostor;
  79696. /**
  79697. * Clones the physics imposter
  79698. * @param newObject The physics imposter clones to this physics-enabled object
  79699. * @returns A nullable physics imposter
  79700. */
  79701. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79702. /**
  79703. * Disposes the physics imposter
  79704. */
  79705. dispose(): void;
  79706. /**
  79707. * Sets the delta position
  79708. * @param position The delta position amount
  79709. */
  79710. setDeltaPosition(position: Vector3): void;
  79711. /**
  79712. * Sets the delta rotation
  79713. * @param rotation The delta rotation amount
  79714. */
  79715. setDeltaRotation(rotation: Quaternion): void;
  79716. /**
  79717. * Gets the box size of the physics imposter and stores the result in the input parameter
  79718. * @param result Stores the box size
  79719. * @returns The physics imposter
  79720. */
  79721. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  79722. /**
  79723. * Gets the radius of the physics imposter
  79724. * @returns Radius of the physics imposter
  79725. */
  79726. getRadius(): number;
  79727. /**
  79728. * Sync a bone with this impostor
  79729. * @param bone The bone to sync to the impostor.
  79730. * @param boneMesh The mesh that the bone is influencing.
  79731. * @param jointPivot The pivot of the joint / bone in local space.
  79732. * @param distToJoint Optional distance from the impostor to the joint.
  79733. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79734. */
  79735. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  79736. /**
  79737. * Sync impostor to a bone
  79738. * @param bone The bone that the impostor will be synced to.
  79739. * @param boneMesh The mesh that the bone is influencing.
  79740. * @param jointPivot The pivot of the joint / bone in local space.
  79741. * @param distToJoint Optional distance from the impostor to the joint.
  79742. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  79743. * @param boneAxis Optional vector3 axis the bone is aligned with
  79744. */
  79745. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  79746. /**
  79747. * No-Imposter type
  79748. */
  79749. static NoImpostor: number;
  79750. /**
  79751. * Sphere-Imposter type
  79752. */
  79753. static SphereImpostor: number;
  79754. /**
  79755. * Box-Imposter type
  79756. */
  79757. static BoxImpostor: number;
  79758. /**
  79759. * Plane-Imposter type
  79760. */
  79761. static PlaneImpostor: number;
  79762. /**
  79763. * Mesh-imposter type
  79764. */
  79765. static MeshImpostor: number;
  79766. /**
  79767. * Cylinder-Imposter type
  79768. */
  79769. static CylinderImpostor: number;
  79770. /**
  79771. * Particle-Imposter type
  79772. */
  79773. static ParticleImpostor: number;
  79774. /**
  79775. * Heightmap-Imposter type
  79776. */
  79777. static HeightmapImpostor: number;
  79778. /**
  79779. * ConvexHull-Impostor type (Ammo.js plugin only)
  79780. */
  79781. static ConvexHullImpostor: number;
  79782. /**
  79783. * Rope-Imposter type
  79784. */
  79785. static RopeImpostor: number;
  79786. /**
  79787. * Cloth-Imposter type
  79788. */
  79789. static ClothImpostor: number;
  79790. /**
  79791. * Softbody-Imposter type
  79792. */
  79793. static SoftbodyImpostor: number;
  79794. }
  79795. }
  79796. declare module BABYLON {
  79797. /**
  79798. * Class used to represent a specific level of detail of a mesh
  79799. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79800. */
  79801. export class MeshLODLevel {
  79802. /** Defines the distance where this level should star being displayed */
  79803. distance: number;
  79804. /** Defines the mesh to use to render this level */
  79805. mesh: Nullable<Mesh>;
  79806. /**
  79807. * Creates a new LOD level
  79808. * @param distance defines the distance where this level should star being displayed
  79809. * @param mesh defines the mesh to use to render this level
  79810. */
  79811. constructor(
  79812. /** Defines the distance where this level should star being displayed */
  79813. distance: number,
  79814. /** Defines the mesh to use to render this level */
  79815. mesh: Nullable<Mesh>);
  79816. }
  79817. /**
  79818. * @hidden
  79819. **/
  79820. export class _CreationDataStorage {
  79821. closePath?: boolean;
  79822. closeArray?: boolean;
  79823. idx: number[];
  79824. dashSize: number;
  79825. gapSize: number;
  79826. path3D: Path3D;
  79827. pathArray: Vector3[][];
  79828. arc: number;
  79829. radius: number;
  79830. cap: number;
  79831. tessellation: number;
  79832. }
  79833. /**
  79834. * @hidden
  79835. **/
  79836. class _InstanceDataStorage {
  79837. visibleInstances: any;
  79838. batchCache: _InstancesBatch;
  79839. instancesBufferSize: number;
  79840. instancesBuffer: Nullable<Buffer>;
  79841. instancesData: Float32Array;
  79842. overridenInstanceCount: number;
  79843. isFrozen: boolean;
  79844. previousBatch: _InstancesBatch;
  79845. hardwareInstancedRendering: boolean;
  79846. sideOrientation: number;
  79847. }
  79848. /**
  79849. * @hidden
  79850. **/
  79851. export class _InstancesBatch {
  79852. mustReturn: boolean;
  79853. visibleInstances: Nullable<InstancedMesh[]>[];
  79854. renderSelf: boolean[];
  79855. hardwareInstancedRendering: boolean[];
  79856. }
  79857. /**
  79858. * Class used to represent renderable models
  79859. */
  79860. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  79861. /**
  79862. * Mesh side orientation : usually the external or front surface
  79863. */
  79864. static readonly FRONTSIDE: number;
  79865. /**
  79866. * Mesh side orientation : usually the internal or back surface
  79867. */
  79868. static readonly BACKSIDE: number;
  79869. /**
  79870. * Mesh side orientation : both internal and external or front and back surfaces
  79871. */
  79872. static readonly DOUBLESIDE: number;
  79873. /**
  79874. * Mesh side orientation : by default, `FRONTSIDE`
  79875. */
  79876. static readonly DEFAULTSIDE: number;
  79877. /**
  79878. * Mesh cap setting : no cap
  79879. */
  79880. static readonly NO_CAP: number;
  79881. /**
  79882. * Mesh cap setting : one cap at the beginning of the mesh
  79883. */
  79884. static readonly CAP_START: number;
  79885. /**
  79886. * Mesh cap setting : one cap at the end of the mesh
  79887. */
  79888. static readonly CAP_END: number;
  79889. /**
  79890. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  79891. */
  79892. static readonly CAP_ALL: number;
  79893. /**
  79894. * Gets the default side orientation.
  79895. * @param orientation the orientation to value to attempt to get
  79896. * @returns the default orientation
  79897. * @hidden
  79898. */
  79899. static _GetDefaultSideOrientation(orientation?: number): number;
  79900. private _onBeforeRenderObservable;
  79901. private _onBeforeBindObservable;
  79902. private _onAfterRenderObservable;
  79903. private _onBeforeDrawObservable;
  79904. /**
  79905. * An event triggered before rendering the mesh
  79906. */
  79907. readonly onBeforeRenderObservable: Observable<Mesh>;
  79908. /**
  79909. * An event triggered before binding the mesh
  79910. */
  79911. readonly onBeforeBindObservable: Observable<Mesh>;
  79912. /**
  79913. * An event triggered after rendering the mesh
  79914. */
  79915. readonly onAfterRenderObservable: Observable<Mesh>;
  79916. /**
  79917. * An event triggered before drawing the mesh
  79918. */
  79919. readonly onBeforeDrawObservable: Observable<Mesh>;
  79920. private _onBeforeDrawObserver;
  79921. /**
  79922. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  79923. */
  79924. onBeforeDraw: () => void;
  79925. /**
  79926. * Gets the delay loading state of the mesh (when delay loading is turned on)
  79927. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  79928. */
  79929. delayLoadState: number;
  79930. /**
  79931. * Gets the list of instances created from this mesh
  79932. * it is not supposed to be modified manually.
  79933. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  79934. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79935. */
  79936. instances: InstancedMesh[];
  79937. /**
  79938. * Gets the file containing delay loading data for this mesh
  79939. */
  79940. delayLoadingFile: string;
  79941. /** @hidden */
  79942. _binaryInfo: any;
  79943. private _LODLevels;
  79944. /**
  79945. * User defined function used to change how LOD level selection is done
  79946. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  79947. */
  79948. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  79949. private _morphTargetManager;
  79950. /**
  79951. * Gets or sets the morph target manager
  79952. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  79953. */
  79954. morphTargetManager: Nullable<MorphTargetManager>;
  79955. /** @hidden */
  79956. _creationDataStorage: Nullable<_CreationDataStorage>;
  79957. /** @hidden */
  79958. _geometry: Nullable<Geometry>;
  79959. /** @hidden */
  79960. _delayInfo: Array<string>;
  79961. /** @hidden */
  79962. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  79963. /** @hidden */
  79964. _instanceDataStorage: _InstanceDataStorage;
  79965. private _effectiveMaterial;
  79966. /** @hidden */
  79967. _shouldGenerateFlatShading: boolean;
  79968. private _preActivateId;
  79969. /** @hidden */
  79970. _originalBuilderSideOrientation: number;
  79971. /**
  79972. * Use this property to change the original side orientation defined at construction time
  79973. */
  79974. overrideMaterialSideOrientation: Nullable<number>;
  79975. private _areNormalsFrozen;
  79976. private _sourcePositions;
  79977. private _sourceNormals;
  79978. private _source;
  79979. private meshMap;
  79980. /**
  79981. * Gets the source mesh (the one used to clone this one from)
  79982. */
  79983. readonly source: Nullable<Mesh>;
  79984. /**
  79985. * Gets or sets a boolean indicating that this mesh does not use index buffer
  79986. */
  79987. isUnIndexed: boolean;
  79988. /**
  79989. * @constructor
  79990. * @param name The value used by scene.getMeshByName() to do a lookup.
  79991. * @param scene The scene to add this mesh to.
  79992. * @param parent The parent of this mesh, if it has one
  79993. * @param source An optional Mesh from which geometry is shared, cloned.
  79994. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79995. * When false, achieved by calling a clone(), also passing False.
  79996. * This will make creation of children, recursive.
  79997. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  79998. */
  79999. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80000. /**
  80001. * Gets the class name
  80002. * @returns the string "Mesh".
  80003. */
  80004. getClassName(): string;
  80005. /** @hidden */
  80006. readonly _isMesh: boolean;
  80007. /**
  80008. * Returns a description of this mesh
  80009. * @param fullDetails define if full details about this mesh must be used
  80010. * @returns a descriptive string representing this mesh
  80011. */
  80012. toString(fullDetails?: boolean): string;
  80013. /** @hidden */
  80014. _unBindEffect(): void;
  80015. /**
  80016. * Gets a boolean indicating if this mesh has LOD
  80017. */
  80018. readonly hasLODLevels: boolean;
  80019. /**
  80020. * Gets the list of MeshLODLevel associated with the current mesh
  80021. * @returns an array of MeshLODLevel
  80022. */
  80023. getLODLevels(): MeshLODLevel[];
  80024. private _sortLODLevels;
  80025. /**
  80026. * Add a mesh as LOD level triggered at the given distance.
  80027. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80028. * @param distance The distance from the center of the object to show this level
  80029. * @param mesh The mesh to be added as LOD level (can be null)
  80030. * @return This mesh (for chaining)
  80031. */
  80032. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80033. /**
  80034. * Returns the LOD level mesh at the passed distance or null if not found.
  80035. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80036. * @param distance The distance from the center of the object to show this level
  80037. * @returns a Mesh or `null`
  80038. */
  80039. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80040. /**
  80041. * Remove a mesh from the LOD array
  80042. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80043. * @param mesh defines the mesh to be removed
  80044. * @return This mesh (for chaining)
  80045. */
  80046. removeLODLevel(mesh: Mesh): Mesh;
  80047. /**
  80048. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80050. * @param camera defines the camera to use to compute distance
  80051. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80052. * @return This mesh (for chaining)
  80053. */
  80054. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80055. /**
  80056. * Gets the mesh internal Geometry object
  80057. */
  80058. readonly geometry: Nullable<Geometry>;
  80059. /**
  80060. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80061. * @returns the total number of vertices
  80062. */
  80063. getTotalVertices(): number;
  80064. /**
  80065. * Returns the content of an associated vertex buffer
  80066. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80067. * - VertexBuffer.PositionKind
  80068. * - VertexBuffer.UVKind
  80069. * - VertexBuffer.UV2Kind
  80070. * - VertexBuffer.UV3Kind
  80071. * - VertexBuffer.UV4Kind
  80072. * - VertexBuffer.UV5Kind
  80073. * - VertexBuffer.UV6Kind
  80074. * - VertexBuffer.ColorKind
  80075. * - VertexBuffer.MatricesIndicesKind
  80076. * - VertexBuffer.MatricesIndicesExtraKind
  80077. * - VertexBuffer.MatricesWeightsKind
  80078. * - VertexBuffer.MatricesWeightsExtraKind
  80079. * @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
  80080. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80081. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80082. */
  80083. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80084. /**
  80085. * Returns the mesh VertexBuffer object from the requested `kind`
  80086. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80087. * - VertexBuffer.PositionKind
  80088. * - VertexBuffer.UVKind
  80089. * - VertexBuffer.UV2Kind
  80090. * - VertexBuffer.UV3Kind
  80091. * - VertexBuffer.UV4Kind
  80092. * - VertexBuffer.UV5Kind
  80093. * - VertexBuffer.UV6Kind
  80094. * - VertexBuffer.ColorKind
  80095. * - VertexBuffer.MatricesIndicesKind
  80096. * - VertexBuffer.MatricesIndicesExtraKind
  80097. * - VertexBuffer.MatricesWeightsKind
  80098. * - VertexBuffer.MatricesWeightsExtraKind
  80099. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80100. */
  80101. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80102. /**
  80103. * Tests if a specific vertex buffer is associated with this mesh
  80104. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80105. * - VertexBuffer.PositionKind
  80106. * - VertexBuffer.UVKind
  80107. * - VertexBuffer.UV2Kind
  80108. * - VertexBuffer.UV3Kind
  80109. * - VertexBuffer.UV4Kind
  80110. * - VertexBuffer.UV5Kind
  80111. * - VertexBuffer.UV6Kind
  80112. * - VertexBuffer.ColorKind
  80113. * - VertexBuffer.MatricesIndicesKind
  80114. * - VertexBuffer.MatricesIndicesExtraKind
  80115. * - VertexBuffer.MatricesWeightsKind
  80116. * - VertexBuffer.MatricesWeightsExtraKind
  80117. * @returns a boolean
  80118. */
  80119. isVerticesDataPresent(kind: string): boolean;
  80120. /**
  80121. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80122. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80123. * - VertexBuffer.PositionKind
  80124. * - VertexBuffer.UVKind
  80125. * - VertexBuffer.UV2Kind
  80126. * - VertexBuffer.UV3Kind
  80127. * - VertexBuffer.UV4Kind
  80128. * - VertexBuffer.UV5Kind
  80129. * - VertexBuffer.UV6Kind
  80130. * - VertexBuffer.ColorKind
  80131. * - VertexBuffer.MatricesIndicesKind
  80132. * - VertexBuffer.MatricesIndicesExtraKind
  80133. * - VertexBuffer.MatricesWeightsKind
  80134. * - VertexBuffer.MatricesWeightsExtraKind
  80135. * @returns a boolean
  80136. */
  80137. isVertexBufferUpdatable(kind: string): boolean;
  80138. /**
  80139. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80140. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80141. * - VertexBuffer.PositionKind
  80142. * - VertexBuffer.UVKind
  80143. * - VertexBuffer.UV2Kind
  80144. * - VertexBuffer.UV3Kind
  80145. * - VertexBuffer.UV4Kind
  80146. * - VertexBuffer.UV5Kind
  80147. * - VertexBuffer.UV6Kind
  80148. * - VertexBuffer.ColorKind
  80149. * - VertexBuffer.MatricesIndicesKind
  80150. * - VertexBuffer.MatricesIndicesExtraKind
  80151. * - VertexBuffer.MatricesWeightsKind
  80152. * - VertexBuffer.MatricesWeightsExtraKind
  80153. * @returns an array of strings
  80154. */
  80155. getVerticesDataKinds(): string[];
  80156. /**
  80157. * Returns a positive integer : the total number of indices in this mesh geometry.
  80158. * @returns the numner of indices or zero if the mesh has no geometry.
  80159. */
  80160. getTotalIndices(): number;
  80161. /**
  80162. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80163. * @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.
  80164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80165. * @returns the indices array or an empty array if the mesh has no geometry
  80166. */
  80167. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80168. readonly isBlocked: boolean;
  80169. /**
  80170. * Determine if the current mesh is ready to be rendered
  80171. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80172. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80173. * @returns true if all associated assets are ready (material, textures, shaders)
  80174. */
  80175. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80176. /**
  80177. * 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.
  80178. */
  80179. readonly areNormalsFrozen: boolean;
  80180. /**
  80181. * 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.
  80182. * @returns the current mesh
  80183. */
  80184. freezeNormals(): Mesh;
  80185. /**
  80186. * 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
  80187. * @returns the current mesh
  80188. */
  80189. unfreezeNormals(): Mesh;
  80190. /**
  80191. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80192. */
  80193. overridenInstanceCount: number;
  80194. /** @hidden */
  80195. _preActivate(): Mesh;
  80196. /** @hidden */
  80197. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80198. /** @hidden */
  80199. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80200. /**
  80201. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80202. * This means the mesh underlying bounding box and sphere are recomputed.
  80203. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80204. * @returns the current mesh
  80205. */
  80206. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80207. /** @hidden */
  80208. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80209. /**
  80210. * This function will subdivide the mesh into multiple submeshes
  80211. * @param count defines the expected number of submeshes
  80212. */
  80213. subdivide(count: number): void;
  80214. /**
  80215. * Copy a FloatArray into a specific associated vertex buffer
  80216. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80217. * - VertexBuffer.PositionKind
  80218. * - VertexBuffer.UVKind
  80219. * - VertexBuffer.UV2Kind
  80220. * - VertexBuffer.UV3Kind
  80221. * - VertexBuffer.UV4Kind
  80222. * - VertexBuffer.UV5Kind
  80223. * - VertexBuffer.UV6Kind
  80224. * - VertexBuffer.ColorKind
  80225. * - VertexBuffer.MatricesIndicesKind
  80226. * - VertexBuffer.MatricesIndicesExtraKind
  80227. * - VertexBuffer.MatricesWeightsKind
  80228. * - VertexBuffer.MatricesWeightsExtraKind
  80229. * @param data defines the data source
  80230. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80231. * @param stride defines the data stride size (can be null)
  80232. * @returns the current mesh
  80233. */
  80234. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80235. /**
  80236. * Flags an associated vertex buffer as updatable
  80237. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80238. * - VertexBuffer.PositionKind
  80239. * - VertexBuffer.UVKind
  80240. * - VertexBuffer.UV2Kind
  80241. * - VertexBuffer.UV3Kind
  80242. * - VertexBuffer.UV4Kind
  80243. * - VertexBuffer.UV5Kind
  80244. * - VertexBuffer.UV6Kind
  80245. * - VertexBuffer.ColorKind
  80246. * - VertexBuffer.MatricesIndicesKind
  80247. * - VertexBuffer.MatricesIndicesExtraKind
  80248. * - VertexBuffer.MatricesWeightsKind
  80249. * - VertexBuffer.MatricesWeightsExtraKind
  80250. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80251. */
  80252. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80253. /**
  80254. * Sets the mesh global Vertex Buffer
  80255. * @param buffer defines the buffer to use
  80256. * @returns the current mesh
  80257. */
  80258. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80259. /**
  80260. * Update a specific associated vertex buffer
  80261. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80262. * - VertexBuffer.PositionKind
  80263. * - VertexBuffer.UVKind
  80264. * - VertexBuffer.UV2Kind
  80265. * - VertexBuffer.UV3Kind
  80266. * - VertexBuffer.UV4Kind
  80267. * - VertexBuffer.UV5Kind
  80268. * - VertexBuffer.UV6Kind
  80269. * - VertexBuffer.ColorKind
  80270. * - VertexBuffer.MatricesIndicesKind
  80271. * - VertexBuffer.MatricesIndicesExtraKind
  80272. * - VertexBuffer.MatricesWeightsKind
  80273. * - VertexBuffer.MatricesWeightsExtraKind
  80274. * @param data defines the data source
  80275. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80276. * @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)
  80277. * @returns the current mesh
  80278. */
  80279. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80280. /**
  80281. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80282. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80283. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80284. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80285. * @returns the current mesh
  80286. */
  80287. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80288. /**
  80289. * Creates a un-shared specific occurence of the geometry for the mesh.
  80290. * @returns the current mesh
  80291. */
  80292. makeGeometryUnique(): Mesh;
  80293. /**
  80294. * Set the index buffer of this mesh
  80295. * @param indices defines the source data
  80296. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80297. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80298. * @returns the current mesh
  80299. */
  80300. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80301. /**
  80302. * Update the current index buffer
  80303. * @param indices defines the source data
  80304. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80305. * @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)
  80306. * @returns the current mesh
  80307. */
  80308. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80309. /**
  80310. * Invert the geometry to move from a right handed system to a left handed one.
  80311. * @returns the current mesh
  80312. */
  80313. toLeftHanded(): Mesh;
  80314. /** @hidden */
  80315. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80316. /** @hidden */
  80317. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80318. /**
  80319. * Registers for this mesh a javascript function called just before the rendering process
  80320. * @param func defines the function to call before rendering this mesh
  80321. * @returns the current mesh
  80322. */
  80323. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80324. /**
  80325. * Disposes a previously registered javascript function called before the rendering
  80326. * @param func defines the function to remove
  80327. * @returns the current mesh
  80328. */
  80329. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80330. /**
  80331. * Registers for this mesh a javascript function called just after the rendering is complete
  80332. * @param func defines the function to call after rendering this mesh
  80333. * @returns the current mesh
  80334. */
  80335. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80336. /**
  80337. * Disposes a previously registered javascript function called after the rendering.
  80338. * @param func defines the function to remove
  80339. * @returns the current mesh
  80340. */
  80341. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80342. /** @hidden */
  80343. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80344. /** @hidden */
  80345. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80346. /** @hidden */
  80347. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80348. /** @hidden */
  80349. _freeze(): void;
  80350. /** @hidden */
  80351. _unFreeze(): void;
  80352. /**
  80353. * 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
  80354. * @param subMesh defines the subMesh to render
  80355. * @param enableAlphaMode defines if alpha mode can be changed
  80356. * @returns the current mesh
  80357. */
  80358. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80359. private _onBeforeDraw;
  80360. /**
  80361. * Renormalize the mesh and patch it up if there are no weights
  80362. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80363. * However in the case of zero weights then we set just a single influence to 1.
  80364. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80365. */
  80366. cleanMatrixWeights(): void;
  80367. private normalizeSkinFourWeights;
  80368. private normalizeSkinWeightsAndExtra;
  80369. /**
  80370. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80371. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80372. * the user know there was an issue with importing the mesh
  80373. * @returns a validation object with skinned, valid and report string
  80374. */
  80375. validateSkinning(): {
  80376. skinned: boolean;
  80377. valid: boolean;
  80378. report: string;
  80379. };
  80380. /** @hidden */
  80381. _checkDelayState(): Mesh;
  80382. private _queueLoad;
  80383. /**
  80384. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80385. * A mesh is in the frustum if its bounding box intersects the frustum
  80386. * @param frustumPlanes defines the frustum to test
  80387. * @returns true if the mesh is in the frustum planes
  80388. */
  80389. isInFrustum(frustumPlanes: Plane[]): boolean;
  80390. /**
  80391. * Sets the mesh material by the material or multiMaterial `id` property
  80392. * @param id is a string identifying the material or the multiMaterial
  80393. * @returns the current mesh
  80394. */
  80395. setMaterialByID(id: string): Mesh;
  80396. /**
  80397. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80398. * @returns an array of IAnimatable
  80399. */
  80400. getAnimatables(): IAnimatable[];
  80401. /**
  80402. * Modifies the mesh geometry according to the passed transformation matrix.
  80403. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80404. * The mesh normals are modified using the same transformation.
  80405. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80406. * @param transform defines the transform matrix to use
  80407. * @see http://doc.babylonjs.com/resources/baking_transformations
  80408. * @returns the current mesh
  80409. */
  80410. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80411. /**
  80412. * Modifies the mesh geometry according to its own current World Matrix.
  80413. * The mesh World Matrix is then reset.
  80414. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80415. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80416. * @see http://doc.babylonjs.com/resources/baking_transformations
  80417. * @returns the current mesh
  80418. */
  80419. bakeCurrentTransformIntoVertices(): Mesh;
  80420. /** @hidden */
  80421. readonly _positions: Nullable<Vector3[]>;
  80422. /** @hidden */
  80423. _resetPointsArrayCache(): Mesh;
  80424. /** @hidden */
  80425. _generatePointsArray(): boolean;
  80426. /**
  80427. * Returns a new Mesh object generated from the current mesh properties.
  80428. * This method must not get confused with createInstance()
  80429. * @param name is a string, the name given to the new mesh
  80430. * @param newParent can be any Node object (default `null`)
  80431. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80432. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80433. * @returns a new mesh
  80434. */
  80435. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80436. /**
  80437. * Releases resources associated with this mesh.
  80438. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80439. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80440. */
  80441. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80442. /**
  80443. * Modifies the mesh geometry according to a displacement map.
  80444. * 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.
  80445. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80446. * @param url is a string, the URL from the image file is to be downloaded.
  80447. * @param minHeight is the lower limit of the displacement.
  80448. * @param maxHeight is the upper limit of the displacement.
  80449. * @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.
  80450. * @param uvOffset is an optional vector2 used to offset UV.
  80451. * @param uvScale is an optional vector2 used to scale UV.
  80452. * @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.
  80453. * @returns the Mesh.
  80454. */
  80455. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80456. /**
  80457. * Modifies the mesh geometry according to a displacementMap buffer.
  80458. * 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.
  80459. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80460. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80461. * @param heightMapWidth is the width of the buffer image.
  80462. * @param heightMapHeight is the height of the buffer image.
  80463. * @param minHeight is the lower limit of the displacement.
  80464. * @param maxHeight is the upper limit of the displacement.
  80465. * @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.
  80466. * @param uvOffset is an optional vector2 used to offset UV.
  80467. * @param uvScale is an optional vector2 used to scale UV.
  80468. * @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.
  80469. * @returns the Mesh.
  80470. */
  80471. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80472. /**
  80473. * Modify the mesh to get a flat shading rendering.
  80474. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80475. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80476. * @returns current mesh
  80477. */
  80478. convertToFlatShadedMesh(): Mesh;
  80479. /**
  80480. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80481. * In other words, more vertices, no more indices and a single bigger VBO.
  80482. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80483. * @returns current mesh
  80484. */
  80485. convertToUnIndexedMesh(): Mesh;
  80486. /**
  80487. * Inverses facet orientations.
  80488. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80489. * @param flipNormals will also inverts the normals
  80490. * @returns current mesh
  80491. */
  80492. flipFaces(flipNormals?: boolean): Mesh;
  80493. /**
  80494. * Increase the number of facets and hence vertices in a mesh
  80495. * Vertex normals are interpolated from existing vertex normals
  80496. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80497. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80498. */
  80499. increaseVertices(numberPerEdge: number): void;
  80500. /**
  80501. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80502. * This will undo any application of covertToFlatShadedMesh
  80503. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80504. */
  80505. forceSharedVertices(): void;
  80506. /** @hidden */
  80507. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80508. /** @hidden */
  80509. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80510. /**
  80511. * Creates a new InstancedMesh object from the mesh model.
  80512. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80513. * @param name defines the name of the new instance
  80514. * @returns a new InstancedMesh
  80515. */
  80516. createInstance(name: string): InstancedMesh;
  80517. /**
  80518. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80519. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80520. * @returns the current mesh
  80521. */
  80522. synchronizeInstances(): Mesh;
  80523. /**
  80524. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80525. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80526. * This should be used together with the simplification to avoid disappearing triangles.
  80527. * @param successCallback an optional success callback to be called after the optimization finished.
  80528. * @returns the current mesh
  80529. */
  80530. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80531. /**
  80532. * Serialize current mesh
  80533. * @param serializationObject defines the object which will receive the serialization data
  80534. */
  80535. serialize(serializationObject: any): void;
  80536. /** @hidden */
  80537. _syncGeometryWithMorphTargetManager(): void;
  80538. /** @hidden */
  80539. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80540. /**
  80541. * Returns a new Mesh object parsed from the source provided.
  80542. * @param parsedMesh is the source
  80543. * @param scene defines the hosting scene
  80544. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80545. * @returns a new Mesh
  80546. */
  80547. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80548. /**
  80549. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80550. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80551. * @param name defines the name of the mesh to create
  80552. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80553. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80554. * @param closePath creates a seam between the first and the last points of each path of the path array
  80555. * @param offset is taken in account only if the `pathArray` is containing a single path
  80556. * @param scene defines the hosting scene
  80557. * @param updatable defines if the mesh must be flagged as updatable
  80558. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80559. * @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)
  80560. * @returns a new Mesh
  80561. */
  80562. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80563. /**
  80564. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80565. * @param name defines the name of the mesh to create
  80566. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80567. * @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
  80568. * @param scene defines the hosting scene
  80569. * @param updatable defines if the mesh must be flagged as updatable
  80570. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80571. * @returns a new Mesh
  80572. */
  80573. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80574. /**
  80575. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80576. * @param name defines the name of the mesh to create
  80577. * @param size sets the size (float) of each box side (default 1)
  80578. * @param scene defines the hosting scene
  80579. * @param updatable defines if the mesh must be flagged as updatable
  80580. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80581. * @returns a new Mesh
  80582. */
  80583. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80584. /**
  80585. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80586. * @param name defines the name of the mesh to create
  80587. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80588. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80589. * @param scene defines the hosting scene
  80590. * @param updatable defines if the mesh must be flagged as updatable
  80591. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80592. * @returns a new Mesh
  80593. */
  80594. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80595. /**
  80596. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80597. * @param name defines the name of the mesh to create
  80598. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80599. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80600. * @param scene defines the hosting scene
  80601. * @returns a new Mesh
  80602. */
  80603. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80604. /**
  80605. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80606. * @param name defines the name of the mesh to create
  80607. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80608. * @param diameterTop set the top cap diameter (floats, default 1)
  80609. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80610. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80611. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80612. * @param scene defines the hosting scene
  80613. * @param updatable defines if the mesh must be flagged as updatable
  80614. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80615. * @returns a new Mesh
  80616. */
  80617. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80618. /**
  80619. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80620. * @param name defines the name of the mesh to create
  80621. * @param diameter sets the diameter size (float) of the torus (default 1)
  80622. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80623. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80624. * @param scene defines the hosting scene
  80625. * @param updatable defines if the mesh must be flagged as updatable
  80626. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80627. * @returns a new Mesh
  80628. */
  80629. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80630. /**
  80631. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80632. * @param name defines the name of the mesh to create
  80633. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80634. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80635. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80636. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80637. * @param p the number of windings on X axis (positive integers, default 2)
  80638. * @param q the number of windings on Y axis (positive integers, default 3)
  80639. * @param scene defines the hosting scene
  80640. * @param updatable defines if the mesh must be flagged as updatable
  80641. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80642. * @returns a new Mesh
  80643. */
  80644. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80645. /**
  80646. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80647. * @param name defines the name of the mesh to create
  80648. * @param points is an array successive Vector3
  80649. * @param scene defines the hosting scene
  80650. * @param updatable defines if the mesh must be flagged as updatable
  80651. * @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).
  80652. * @returns a new Mesh
  80653. */
  80654. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80655. /**
  80656. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80657. * @param name defines the name of the mesh to create
  80658. * @param points is an array successive Vector3
  80659. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80660. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80661. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80662. * @param scene defines the hosting scene
  80663. * @param updatable defines if the mesh must be flagged as updatable
  80664. * @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)
  80665. * @returns a new Mesh
  80666. */
  80667. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80668. /**
  80669. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80670. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80671. * 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.
  80672. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80673. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80674. * Remember you can only change the shape positions, not their number when updating a polygon.
  80675. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80676. * @param name defines the name of the mesh to create
  80677. * @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
  80678. * @param scene defines the hosting scene
  80679. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80680. * @param updatable defines if the mesh must be flagged as updatable
  80681. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80682. * @param earcutInjection can be used to inject your own earcut reference
  80683. * @returns a new Mesh
  80684. */
  80685. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80686. /**
  80687. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80688. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80689. * @param name defines the name of the mesh to create
  80690. * @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
  80691. * @param depth defines the height of extrusion
  80692. * @param scene defines the hosting scene
  80693. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80694. * @param updatable defines if the mesh must be flagged as updatable
  80695. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80696. * @param earcutInjection can be used to inject your own earcut reference
  80697. * @returns a new Mesh
  80698. */
  80699. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80700. /**
  80701. * Creates an extruded shape mesh.
  80702. * 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
  80703. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80704. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80705. * @param name defines the name of the mesh to create
  80706. * @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
  80707. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80708. * @param scale is the value to scale the shape
  80709. * @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
  80710. * @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
  80711. * @param scene defines the hosting scene
  80712. * @param updatable defines if the mesh must be flagged as updatable
  80713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80714. * @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)
  80715. * @returns a new Mesh
  80716. */
  80717. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80718. /**
  80719. * Creates an custom extruded shape mesh.
  80720. * The custom extrusion is a parametric shape.
  80721. * It has no predefined shape. Its final shape will depend on the input parameters.
  80722. * Please consider using the same method from the MeshBuilder class instead
  80723. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80724. * @param name defines the name of the mesh to create
  80725. * @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
  80726. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80727. * @param scaleFunction is a custom Javascript function called on each path point
  80728. * @param rotationFunction is a custom Javascript function called on each path point
  80729. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  80730. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  80731. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  80732. * @param scene defines the hosting scene
  80733. * @param updatable defines if the mesh must be flagged as updatable
  80734. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80735. * @param instance is an instance of an existing 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)
  80736. * @returns a new Mesh
  80737. */
  80738. 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;
  80739. /**
  80740. * Creates lathe mesh.
  80741. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  80742. * Please consider using the same method from the MeshBuilder class instead
  80743. * @param name defines the name of the mesh to create
  80744. * @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
  80745. * @param radius is the radius value of the lathe
  80746. * @param tessellation is the side number of the lathe.
  80747. * @param scene defines the hosting scene
  80748. * @param updatable defines if the mesh must be flagged as updatable
  80749. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80750. * @returns a new Mesh
  80751. */
  80752. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80753. /**
  80754. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  80755. * @param name defines the name of the mesh to create
  80756. * @param size sets the size (float) of both sides of the plane at once (default 1)
  80757. * @param scene defines the hosting scene
  80758. * @param updatable defines if the mesh must be flagged as updatable
  80759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80760. * @returns a new Mesh
  80761. */
  80762. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80763. /**
  80764. * Creates a ground mesh.
  80765. * Please consider using the same method from the MeshBuilder class instead
  80766. * @param name defines the name of the mesh to create
  80767. * @param width set the width of the ground
  80768. * @param height set the height of the ground
  80769. * @param subdivisions sets the number of subdivisions per side
  80770. * @param scene defines the hosting scene
  80771. * @param updatable defines if the mesh must be flagged as updatable
  80772. * @returns a new Mesh
  80773. */
  80774. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  80775. /**
  80776. * Creates a tiled ground mesh.
  80777. * Please consider using the same method from the MeshBuilder class instead
  80778. * @param name defines the name of the mesh to create
  80779. * @param xmin set the ground minimum X coordinate
  80780. * @param zmin set the ground minimum Y coordinate
  80781. * @param xmax set the ground maximum X coordinate
  80782. * @param zmax set the ground maximum Z coordinate
  80783. * @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
  80784. * @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
  80785. * @param scene defines the hosting scene
  80786. * @param updatable defines if the mesh must be flagged as updatable
  80787. * @returns a new Mesh
  80788. */
  80789. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  80790. w: number;
  80791. h: number;
  80792. }, precision: {
  80793. w: number;
  80794. h: number;
  80795. }, scene: Scene, updatable?: boolean): Mesh;
  80796. /**
  80797. * Creates a ground mesh from a height map.
  80798. * Please consider using the same method from the MeshBuilder class instead
  80799. * @see http://doc.babylonjs.com/babylon101/height_map
  80800. * @param name defines the name of the mesh to create
  80801. * @param url sets the URL of the height map image resource
  80802. * @param width set the ground width size
  80803. * @param height set the ground height size
  80804. * @param subdivisions sets the number of subdivision per side
  80805. * @param minHeight is the minimum altitude on the ground
  80806. * @param maxHeight is the maximum altitude on the ground
  80807. * @param scene defines the hosting scene
  80808. * @param updatable defines if the mesh must be flagged as updatable
  80809. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  80810. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  80811. * @returns a new Mesh
  80812. */
  80813. 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;
  80814. /**
  80815. * Creates a tube mesh.
  80816. * The tube is a parametric shape.
  80817. * It has no predefined shape. Its final shape will depend on the input parameters.
  80818. * Please consider using the same method from the MeshBuilder class instead
  80819. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80820. * @param name defines the name of the mesh to create
  80821. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  80822. * @param radius sets the tube radius size
  80823. * @param tessellation is the number of sides on the tubular surface
  80824. * @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
  80825. * @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
  80826. * @param scene defines the hosting scene
  80827. * @param updatable defines if the mesh must be flagged as updatable
  80828. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80829. * @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)
  80830. * @returns a new Mesh
  80831. */
  80832. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  80833. (i: number, distance: number): number;
  80834. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80835. /**
  80836. * Creates a polyhedron mesh.
  80837. * Please consider using the same method from the MeshBuilder class instead.
  80838. * * 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
  80839. * * The parameter `size` (positive float, default 1) sets the polygon size
  80840. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  80841. * * 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`
  80842. * * 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
  80843. * * 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)`)
  80844. * * 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
  80845. * * 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
  80846. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80847. * * If you create a double-sided mesh, you can choose what parts of 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
  80848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80849. * @param name defines the name of the mesh to create
  80850. * @param options defines the options used to create the mesh
  80851. * @param scene defines the hosting scene
  80852. * @returns a new Mesh
  80853. */
  80854. static CreatePolyhedron(name: string, options: {
  80855. type?: number;
  80856. size?: number;
  80857. sizeX?: number;
  80858. sizeY?: number;
  80859. sizeZ?: number;
  80860. custom?: any;
  80861. faceUV?: Vector4[];
  80862. faceColors?: Color4[];
  80863. updatable?: boolean;
  80864. sideOrientation?: number;
  80865. }, scene: Scene): Mesh;
  80866. /**
  80867. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  80868. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  80869. * * 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`)
  80870. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  80871. * * 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
  80872. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80873. * * If you create a double-sided mesh, you can choose what parts of 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
  80874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  80875. * @param name defines the name of the mesh
  80876. * @param options defines the options used to create the mesh
  80877. * @param scene defines the hosting scene
  80878. * @returns a new Mesh
  80879. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  80880. */
  80881. static CreateIcoSphere(name: string, options: {
  80882. radius?: number;
  80883. flat?: boolean;
  80884. subdivisions?: number;
  80885. sideOrientation?: number;
  80886. updatable?: boolean;
  80887. }, scene: Scene): Mesh;
  80888. /**
  80889. * Creates a decal mesh.
  80890. * Please consider using the same method from the MeshBuilder class instead.
  80891. * A decal is a mesh usually applied as a model onto the surface of another mesh
  80892. * @param name defines the name of the mesh
  80893. * @param sourceMesh defines the mesh receiving the decal
  80894. * @param position sets the position of the decal in world coordinates
  80895. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  80896. * @param size sets the decal scaling
  80897. * @param angle sets the angle to rotate the decal
  80898. * @returns a new Mesh
  80899. */
  80900. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  80901. /**
  80902. * Prepare internal position array for software CPU skinning
  80903. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  80904. */
  80905. setPositionsForCPUSkinning(): Float32Array;
  80906. /**
  80907. * Prepare internal normal array for software CPU skinning
  80908. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  80909. */
  80910. setNormalsForCPUSkinning(): Float32Array;
  80911. /**
  80912. * Updates the vertex buffer by applying transformation from the bones
  80913. * @param skeleton defines the skeleton to apply to current mesh
  80914. * @returns the current mesh
  80915. */
  80916. applySkeleton(skeleton: Skeleton): Mesh;
  80917. /**
  80918. * 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
  80919. * @param meshes defines the list of meshes to scan
  80920. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  80921. */
  80922. static MinMax(meshes: AbstractMesh[]): {
  80923. min: Vector3;
  80924. max: Vector3;
  80925. };
  80926. /**
  80927. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  80928. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  80929. * @returns a vector3
  80930. */
  80931. static Center(meshesOrMinMaxVector: {
  80932. min: Vector3;
  80933. max: Vector3;
  80934. } | AbstractMesh[]): Vector3;
  80935. /**
  80936. * Merge the array of meshes into a single mesh for performance reasons.
  80937. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  80938. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  80939. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  80940. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  80941. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  80942. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  80943. * @returns a new mesh
  80944. */
  80945. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  80946. /** @hidden */
  80947. addInstance(instance: InstancedMesh): void;
  80948. /** @hidden */
  80949. removeInstance(instance: InstancedMesh): void;
  80950. }
  80951. }
  80952. declare module BABYLON {
  80953. /**
  80954. * Base class for the main features of a material in Babylon.js
  80955. */
  80956. export class Material implements IAnimatable {
  80957. /**
  80958. * Returns the triangle fill mode
  80959. */
  80960. static readonly TriangleFillMode: number;
  80961. /**
  80962. * Returns the wireframe mode
  80963. */
  80964. static readonly WireFrameFillMode: number;
  80965. /**
  80966. * Returns the point fill mode
  80967. */
  80968. static readonly PointFillMode: number;
  80969. /**
  80970. * Returns the point list draw mode
  80971. */
  80972. static readonly PointListDrawMode: number;
  80973. /**
  80974. * Returns the line list draw mode
  80975. */
  80976. static readonly LineListDrawMode: number;
  80977. /**
  80978. * Returns the line loop draw mode
  80979. */
  80980. static readonly LineLoopDrawMode: number;
  80981. /**
  80982. * Returns the line strip draw mode
  80983. */
  80984. static readonly LineStripDrawMode: number;
  80985. /**
  80986. * Returns the triangle strip draw mode
  80987. */
  80988. static readonly TriangleStripDrawMode: number;
  80989. /**
  80990. * Returns the triangle fan draw mode
  80991. */
  80992. static readonly TriangleFanDrawMode: number;
  80993. /**
  80994. * Stores the clock-wise side orientation
  80995. */
  80996. static readonly ClockWiseSideOrientation: number;
  80997. /**
  80998. * Stores the counter clock-wise side orientation
  80999. */
  81000. static readonly CounterClockWiseSideOrientation: number;
  81001. /**
  81002. * The dirty texture flag value
  81003. */
  81004. static readonly TextureDirtyFlag: number;
  81005. /**
  81006. * The dirty light flag value
  81007. */
  81008. static readonly LightDirtyFlag: number;
  81009. /**
  81010. * The dirty fresnel flag value
  81011. */
  81012. static readonly FresnelDirtyFlag: number;
  81013. /**
  81014. * The dirty attribute flag value
  81015. */
  81016. static readonly AttributesDirtyFlag: number;
  81017. /**
  81018. * The dirty misc flag value
  81019. */
  81020. static readonly MiscDirtyFlag: number;
  81021. /**
  81022. * The all dirty flag value
  81023. */
  81024. static readonly AllDirtyFlag: number;
  81025. /**
  81026. * The ID of the material
  81027. */
  81028. id: string;
  81029. /**
  81030. * Gets or sets the unique id of the material
  81031. */
  81032. uniqueId: number;
  81033. /**
  81034. * The name of the material
  81035. */
  81036. name: string;
  81037. /**
  81038. * Gets or sets user defined metadata
  81039. */
  81040. metadata: any;
  81041. /**
  81042. * For internal use only. Please do not use.
  81043. */
  81044. reservedDataStore: any;
  81045. /**
  81046. * Specifies if the ready state should be checked on each call
  81047. */
  81048. checkReadyOnEveryCall: boolean;
  81049. /**
  81050. * Specifies if the ready state should be checked once
  81051. */
  81052. checkReadyOnlyOnce: boolean;
  81053. /**
  81054. * The state of the material
  81055. */
  81056. state: string;
  81057. /**
  81058. * The alpha value of the material
  81059. */
  81060. protected _alpha: number;
  81061. /**
  81062. * List of inspectable custom properties (used by the Inspector)
  81063. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81064. */
  81065. inspectableCustomProperties: IInspectable[];
  81066. /**
  81067. * Sets the alpha value of the material
  81068. */
  81069. /**
  81070. * Gets the alpha value of the material
  81071. */
  81072. alpha: number;
  81073. /**
  81074. * Specifies if back face culling is enabled
  81075. */
  81076. protected _backFaceCulling: boolean;
  81077. /**
  81078. * Sets the back-face culling state
  81079. */
  81080. /**
  81081. * Gets the back-face culling state
  81082. */
  81083. backFaceCulling: boolean;
  81084. /**
  81085. * Stores the value for side orientation
  81086. */
  81087. sideOrientation: number;
  81088. /**
  81089. * Callback triggered when the material is compiled
  81090. */
  81091. onCompiled: Nullable<(effect: Effect) => void>;
  81092. /**
  81093. * Callback triggered when an error occurs
  81094. */
  81095. onError: Nullable<(effect: Effect, errors: string) => void>;
  81096. /**
  81097. * Callback triggered to get the render target textures
  81098. */
  81099. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  81100. /**
  81101. * Gets a boolean indicating that current material needs to register RTT
  81102. */
  81103. readonly hasRenderTargetTextures: boolean;
  81104. /**
  81105. * Specifies if the material should be serialized
  81106. */
  81107. doNotSerialize: boolean;
  81108. /**
  81109. * @hidden
  81110. */
  81111. _storeEffectOnSubMeshes: boolean;
  81112. /**
  81113. * Stores the animations for the material
  81114. */
  81115. animations: Nullable<Array<Animation>>;
  81116. /**
  81117. * An event triggered when the material is disposed
  81118. */
  81119. onDisposeObservable: Observable<Material>;
  81120. /**
  81121. * An observer which watches for dispose events
  81122. */
  81123. private _onDisposeObserver;
  81124. private _onUnBindObservable;
  81125. /**
  81126. * Called during a dispose event
  81127. */
  81128. onDispose: () => void;
  81129. private _onBindObservable;
  81130. /**
  81131. * An event triggered when the material is bound
  81132. */
  81133. readonly onBindObservable: Observable<AbstractMesh>;
  81134. /**
  81135. * An observer which watches for bind events
  81136. */
  81137. private _onBindObserver;
  81138. /**
  81139. * Called during a bind event
  81140. */
  81141. onBind: (Mesh: AbstractMesh) => void;
  81142. /**
  81143. * An event triggered when the material is unbound
  81144. */
  81145. readonly onUnBindObservable: Observable<Material>;
  81146. /**
  81147. * Stores the value of the alpha mode
  81148. */
  81149. private _alphaMode;
  81150. /**
  81151. * Sets the value of the alpha mode.
  81152. *
  81153. * | Value | Type | Description |
  81154. * | --- | --- | --- |
  81155. * | 0 | ALPHA_DISABLE | |
  81156. * | 1 | ALPHA_ADD | |
  81157. * | 2 | ALPHA_COMBINE | |
  81158. * | 3 | ALPHA_SUBTRACT | |
  81159. * | 4 | ALPHA_MULTIPLY | |
  81160. * | 5 | ALPHA_MAXIMIZED | |
  81161. * | 6 | ALPHA_ONEONE | |
  81162. * | 7 | ALPHA_PREMULTIPLIED | |
  81163. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81164. * | 9 | ALPHA_INTERPOLATE | |
  81165. * | 10 | ALPHA_SCREENMODE | |
  81166. *
  81167. */
  81168. /**
  81169. * Gets the value of the alpha mode
  81170. */
  81171. alphaMode: number;
  81172. /**
  81173. * Stores the state of the need depth pre-pass value
  81174. */
  81175. private _needDepthPrePass;
  81176. /**
  81177. * Sets the need depth pre-pass value
  81178. */
  81179. /**
  81180. * Gets the depth pre-pass value
  81181. */
  81182. needDepthPrePass: boolean;
  81183. /**
  81184. * Specifies if depth writing should be disabled
  81185. */
  81186. disableDepthWrite: boolean;
  81187. /**
  81188. * Specifies if depth writing should be forced
  81189. */
  81190. forceDepthWrite: boolean;
  81191. /**
  81192. * Specifies if there should be a separate pass for culling
  81193. */
  81194. separateCullingPass: boolean;
  81195. /**
  81196. * Stores the state specifing if fog should be enabled
  81197. */
  81198. private _fogEnabled;
  81199. /**
  81200. * Sets the state for enabling fog
  81201. */
  81202. /**
  81203. * Gets the value of the fog enabled state
  81204. */
  81205. fogEnabled: boolean;
  81206. /**
  81207. * Stores the size of points
  81208. */
  81209. pointSize: number;
  81210. /**
  81211. * Stores the z offset value
  81212. */
  81213. zOffset: number;
  81214. /**
  81215. * Gets a value specifying if wireframe mode is enabled
  81216. */
  81217. /**
  81218. * Sets the state of wireframe mode
  81219. */
  81220. wireframe: boolean;
  81221. /**
  81222. * Gets the value specifying if point clouds are enabled
  81223. */
  81224. /**
  81225. * Sets the state of point cloud mode
  81226. */
  81227. pointsCloud: boolean;
  81228. /**
  81229. * Gets the material fill mode
  81230. */
  81231. /**
  81232. * Sets the material fill mode
  81233. */
  81234. fillMode: number;
  81235. /**
  81236. * @hidden
  81237. * Stores the effects for the material
  81238. */
  81239. _effect: Nullable<Effect>;
  81240. /**
  81241. * @hidden
  81242. * Specifies if the material was previously ready
  81243. */
  81244. _wasPreviouslyReady: boolean;
  81245. /**
  81246. * Specifies if uniform buffers should be used
  81247. */
  81248. private _useUBO;
  81249. /**
  81250. * Stores a reference to the scene
  81251. */
  81252. private _scene;
  81253. /**
  81254. * Stores the fill mode state
  81255. */
  81256. private _fillMode;
  81257. /**
  81258. * Specifies if the depth write state should be cached
  81259. */
  81260. private _cachedDepthWriteState;
  81261. /**
  81262. * Stores the uniform buffer
  81263. */
  81264. protected _uniformBuffer: UniformBuffer;
  81265. /** @hidden */
  81266. _indexInSceneMaterialArray: number;
  81267. /** @hidden */
  81268. meshMap: Nullable<{
  81269. [id: string]: AbstractMesh | undefined;
  81270. }>;
  81271. /**
  81272. * Creates a material instance
  81273. * @param name defines the name of the material
  81274. * @param scene defines the scene to reference
  81275. * @param doNotAdd specifies if the material should be added to the scene
  81276. */
  81277. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81278. /**
  81279. * Returns a string representation of the current material
  81280. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81281. * @returns a string with material information
  81282. */
  81283. toString(fullDetails?: boolean): string;
  81284. /**
  81285. * Gets the class name of the material
  81286. * @returns a string with the class name of the material
  81287. */
  81288. getClassName(): string;
  81289. /**
  81290. * Specifies if updates for the material been locked
  81291. */
  81292. readonly isFrozen: boolean;
  81293. /**
  81294. * Locks updates for the material
  81295. */
  81296. freeze(): void;
  81297. /**
  81298. * Unlocks updates for the material
  81299. */
  81300. unfreeze(): void;
  81301. /**
  81302. * Specifies if the material is ready to be used
  81303. * @param mesh defines the mesh to check
  81304. * @param useInstances specifies if instances should be used
  81305. * @returns a boolean indicating if the material is ready to be used
  81306. */
  81307. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81308. /**
  81309. * Specifies that the submesh is ready to be used
  81310. * @param mesh defines the mesh to check
  81311. * @param subMesh defines which submesh to check
  81312. * @param useInstances specifies that instances should be used
  81313. * @returns a boolean indicating that the submesh is ready or not
  81314. */
  81315. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81316. /**
  81317. * Returns the material effect
  81318. * @returns the effect associated with the material
  81319. */
  81320. getEffect(): Nullable<Effect>;
  81321. /**
  81322. * Returns the current scene
  81323. * @returns a Scene
  81324. */
  81325. getScene(): Scene;
  81326. /**
  81327. * Specifies if the material will require alpha blending
  81328. * @returns a boolean specifying if alpha blending is needed
  81329. */
  81330. needAlphaBlending(): boolean;
  81331. /**
  81332. * Specifies if the mesh will require alpha blending
  81333. * @param mesh defines the mesh to check
  81334. * @returns a boolean specifying if alpha blending is needed for the mesh
  81335. */
  81336. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81337. /**
  81338. * Specifies if this material should be rendered in alpha test mode
  81339. * @returns a boolean specifying if an alpha test is needed.
  81340. */
  81341. needAlphaTesting(): boolean;
  81342. /**
  81343. * Gets the texture used for the alpha test
  81344. * @returns the texture to use for alpha testing
  81345. */
  81346. getAlphaTestTexture(): Nullable<BaseTexture>;
  81347. /**
  81348. * Marks the material to indicate that it needs to be re-calculated
  81349. */
  81350. markDirty(): void;
  81351. /** @hidden */
  81352. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81353. /**
  81354. * Binds the material to the mesh
  81355. * @param world defines the world transformation matrix
  81356. * @param mesh defines the mesh to bind the material to
  81357. */
  81358. bind(world: Matrix, mesh?: Mesh): void;
  81359. /**
  81360. * Binds the submesh to the material
  81361. * @param world defines the world transformation matrix
  81362. * @param mesh defines the mesh containing the submesh
  81363. * @param subMesh defines the submesh to bind the material to
  81364. */
  81365. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81366. /**
  81367. * Binds the world matrix to the material
  81368. * @param world defines the world transformation matrix
  81369. */
  81370. bindOnlyWorldMatrix(world: Matrix): void;
  81371. /**
  81372. * Binds the scene's uniform buffer to the effect.
  81373. * @param effect defines the effect to bind to the scene uniform buffer
  81374. * @param sceneUbo defines the uniform buffer storing scene data
  81375. */
  81376. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81377. /**
  81378. * Binds the view matrix to the effect
  81379. * @param effect defines the effect to bind the view matrix to
  81380. */
  81381. bindView(effect: Effect): void;
  81382. /**
  81383. * Binds the view projection matrix to the effect
  81384. * @param effect defines the effect to bind the view projection matrix to
  81385. */
  81386. bindViewProjection(effect: Effect): void;
  81387. /**
  81388. * Specifies if material alpha testing should be turned on for the mesh
  81389. * @param mesh defines the mesh to check
  81390. */
  81391. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81392. /**
  81393. * Processes to execute after binding the material to a mesh
  81394. * @param mesh defines the rendered mesh
  81395. */
  81396. protected _afterBind(mesh?: Mesh): void;
  81397. /**
  81398. * Unbinds the material from the mesh
  81399. */
  81400. unbind(): void;
  81401. /**
  81402. * Gets the active textures from the material
  81403. * @returns an array of textures
  81404. */
  81405. getActiveTextures(): BaseTexture[];
  81406. /**
  81407. * Specifies if the material uses a texture
  81408. * @param texture defines the texture to check against the material
  81409. * @returns a boolean specifying if the material uses the texture
  81410. */
  81411. hasTexture(texture: BaseTexture): boolean;
  81412. /**
  81413. * Makes a duplicate of the material, and gives it a new name
  81414. * @param name defines the new name for the duplicated material
  81415. * @returns the cloned material
  81416. */
  81417. clone(name: string): Nullable<Material>;
  81418. /**
  81419. * Gets the meshes bound to the material
  81420. * @returns an array of meshes bound to the material
  81421. */
  81422. getBindedMeshes(): AbstractMesh[];
  81423. /**
  81424. * Force shader compilation
  81425. * @param mesh defines the mesh associated with this material
  81426. * @param onCompiled defines a function to execute once the material is compiled
  81427. * @param options defines the options to configure the compilation
  81428. */
  81429. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81430. clipPlane: boolean;
  81431. }>): void;
  81432. /**
  81433. * Force shader compilation
  81434. * @param mesh defines the mesh that will use this material
  81435. * @param options defines additional options for compiling the shaders
  81436. * @returns a promise that resolves when the compilation completes
  81437. */
  81438. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81439. clipPlane: boolean;
  81440. }>): Promise<void>;
  81441. private static readonly _ImageProcessingDirtyCallBack;
  81442. private static readonly _TextureDirtyCallBack;
  81443. private static readonly _FresnelDirtyCallBack;
  81444. private static readonly _MiscDirtyCallBack;
  81445. private static readonly _LightsDirtyCallBack;
  81446. private static readonly _AttributeDirtyCallBack;
  81447. private static _FresnelAndMiscDirtyCallBack;
  81448. private static _TextureAndMiscDirtyCallBack;
  81449. private static readonly _DirtyCallbackArray;
  81450. private static readonly _RunDirtyCallBacks;
  81451. /**
  81452. * Marks a define in the material to indicate that it needs to be re-computed
  81453. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81454. */
  81455. markAsDirty(flag: number): void;
  81456. /**
  81457. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81458. * @param func defines a function which checks material defines against the submeshes
  81459. */
  81460. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81461. /**
  81462. * Indicates that image processing needs to be re-calculated for all submeshes
  81463. */
  81464. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81465. /**
  81466. * Indicates that textures need to be re-calculated for all submeshes
  81467. */
  81468. protected _markAllSubMeshesAsTexturesDirty(): void;
  81469. /**
  81470. * Indicates that fresnel needs to be re-calculated for all submeshes
  81471. */
  81472. protected _markAllSubMeshesAsFresnelDirty(): void;
  81473. /**
  81474. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81475. */
  81476. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81477. /**
  81478. * Indicates that lights need to be re-calculated for all submeshes
  81479. */
  81480. protected _markAllSubMeshesAsLightsDirty(): void;
  81481. /**
  81482. * Indicates that attributes need to be re-calculated for all submeshes
  81483. */
  81484. protected _markAllSubMeshesAsAttributesDirty(): void;
  81485. /**
  81486. * Indicates that misc needs to be re-calculated for all submeshes
  81487. */
  81488. protected _markAllSubMeshesAsMiscDirty(): void;
  81489. /**
  81490. * Indicates that textures and misc need to be re-calculated for all submeshes
  81491. */
  81492. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81493. /**
  81494. * Disposes the material
  81495. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81496. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81497. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81498. */
  81499. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81500. /** @hidden */
  81501. private releaseVertexArrayObject;
  81502. /**
  81503. * Serializes this material
  81504. * @returns the serialized material object
  81505. */
  81506. serialize(): any;
  81507. /**
  81508. * Creates a material from parsed material data
  81509. * @param parsedMaterial defines parsed material data
  81510. * @param scene defines the hosting scene
  81511. * @param rootUrl defines the root URL to use to load textures
  81512. * @returns a new material
  81513. */
  81514. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. /**
  81519. * Base class for submeshes
  81520. */
  81521. export class BaseSubMesh {
  81522. /** @hidden */
  81523. _materialDefines: Nullable<MaterialDefines>;
  81524. /** @hidden */
  81525. _materialEffect: Nullable<Effect>;
  81526. /**
  81527. * Gets associated effect
  81528. */
  81529. readonly effect: Nullable<Effect>;
  81530. /**
  81531. * Sets associated effect (effect used to render this submesh)
  81532. * @param effect defines the effect to associate with
  81533. * @param defines defines the set of defines used to compile this effect
  81534. */
  81535. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81536. }
  81537. /**
  81538. * Defines a subdivision inside a mesh
  81539. */
  81540. export class SubMesh extends BaseSubMesh implements ICullable {
  81541. /** the material index to use */
  81542. materialIndex: number;
  81543. /** vertex index start */
  81544. verticesStart: number;
  81545. /** vertices count */
  81546. verticesCount: number;
  81547. /** index start */
  81548. indexStart: number;
  81549. /** indices count */
  81550. indexCount: number;
  81551. /** @hidden */
  81552. _linesIndexCount: number;
  81553. private _mesh;
  81554. private _renderingMesh;
  81555. private _boundingInfo;
  81556. private _linesIndexBuffer;
  81557. /** @hidden */
  81558. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81559. /** @hidden */
  81560. _trianglePlanes: Plane[];
  81561. /** @hidden */
  81562. _lastColliderTransformMatrix: Nullable<Matrix>;
  81563. /** @hidden */
  81564. _renderId: number;
  81565. /** @hidden */
  81566. _alphaIndex: number;
  81567. /** @hidden */
  81568. _distanceToCamera: number;
  81569. /** @hidden */
  81570. _id: number;
  81571. private _currentMaterial;
  81572. /**
  81573. * Add a new submesh to a mesh
  81574. * @param materialIndex defines the material index to use
  81575. * @param verticesStart defines vertex index start
  81576. * @param verticesCount defines vertices count
  81577. * @param indexStart defines index start
  81578. * @param indexCount defines indices count
  81579. * @param mesh defines the parent mesh
  81580. * @param renderingMesh defines an optional rendering mesh
  81581. * @param createBoundingBox defines if bounding box should be created for this submesh
  81582. * @returns the new submesh
  81583. */
  81584. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81585. /**
  81586. * Creates a new submesh
  81587. * @param materialIndex defines the material index to use
  81588. * @param verticesStart defines vertex index start
  81589. * @param verticesCount defines vertices count
  81590. * @param indexStart defines index start
  81591. * @param indexCount defines indices count
  81592. * @param mesh defines the parent mesh
  81593. * @param renderingMesh defines an optional rendering mesh
  81594. * @param createBoundingBox defines if bounding box should be created for this submesh
  81595. */
  81596. constructor(
  81597. /** the material index to use */
  81598. materialIndex: number,
  81599. /** vertex index start */
  81600. verticesStart: number,
  81601. /** vertices count */
  81602. verticesCount: number,
  81603. /** index start */
  81604. indexStart: number,
  81605. /** indices count */
  81606. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81607. /**
  81608. * Returns true if this submesh covers the entire parent mesh
  81609. * @ignorenaming
  81610. */
  81611. readonly IsGlobal: boolean;
  81612. /**
  81613. * Returns the submesh BoudingInfo object
  81614. * @returns current bounding info (or mesh's one if the submesh is global)
  81615. */
  81616. getBoundingInfo(): BoundingInfo;
  81617. /**
  81618. * Sets the submesh BoundingInfo
  81619. * @param boundingInfo defines the new bounding info to use
  81620. * @returns the SubMesh
  81621. */
  81622. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81623. /**
  81624. * Returns the mesh of the current submesh
  81625. * @return the parent mesh
  81626. */
  81627. getMesh(): AbstractMesh;
  81628. /**
  81629. * Returns the rendering mesh of the submesh
  81630. * @returns the rendering mesh (could be different from parent mesh)
  81631. */
  81632. getRenderingMesh(): Mesh;
  81633. /**
  81634. * Returns the submesh material
  81635. * @returns null or the current material
  81636. */
  81637. getMaterial(): Nullable<Material>;
  81638. /**
  81639. * Sets a new updated BoundingInfo object to the submesh
  81640. * @returns the SubMesh
  81641. */
  81642. refreshBoundingInfo(): SubMesh;
  81643. /** @hidden */
  81644. _checkCollision(collider: Collider): boolean;
  81645. /**
  81646. * Updates the submesh BoundingInfo
  81647. * @param world defines the world matrix to use to update the bounding info
  81648. * @returns the submesh
  81649. */
  81650. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81651. /**
  81652. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81653. * @param frustumPlanes defines the frustum planes
  81654. * @returns true if the submesh is intersecting with the frustum
  81655. */
  81656. isInFrustum(frustumPlanes: Plane[]): boolean;
  81657. /**
  81658. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81659. * @param frustumPlanes defines the frustum planes
  81660. * @returns true if the submesh is inside the frustum
  81661. */
  81662. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81663. /**
  81664. * Renders the submesh
  81665. * @param enableAlphaMode defines if alpha needs to be used
  81666. * @returns the submesh
  81667. */
  81668. render(enableAlphaMode: boolean): SubMesh;
  81669. /**
  81670. * @hidden
  81671. */
  81672. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81673. /**
  81674. * Checks if the submesh intersects with a ray
  81675. * @param ray defines the ray to test
  81676. * @returns true is the passed ray intersects the submesh bounding box
  81677. */
  81678. canIntersects(ray: Ray): boolean;
  81679. /**
  81680. * Intersects current submesh with a ray
  81681. * @param ray defines the ray to test
  81682. * @param positions defines mesh's positions array
  81683. * @param indices defines mesh's indices array
  81684. * @param fastCheck defines if only bounding info should be used
  81685. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81686. * @returns intersection info or null if no intersection
  81687. */
  81688. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81689. /** @hidden */
  81690. private _intersectLines;
  81691. /** @hidden */
  81692. private _intersectTriangles;
  81693. /** @hidden */
  81694. _rebuild(): void;
  81695. /**
  81696. * Creates a new submesh from the passed mesh
  81697. * @param newMesh defines the new hosting mesh
  81698. * @param newRenderingMesh defines an optional rendering mesh
  81699. * @returns the new submesh
  81700. */
  81701. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81702. /**
  81703. * Release associated resources
  81704. */
  81705. dispose(): void;
  81706. /**
  81707. * Gets the class name
  81708. * @returns the string "SubMesh".
  81709. */
  81710. getClassName(): string;
  81711. /**
  81712. * Creates a new submesh from indices data
  81713. * @param materialIndex the index of the main mesh material
  81714. * @param startIndex the index where to start the copy in the mesh indices array
  81715. * @param indexCount the number of indices to copy then from the startIndex
  81716. * @param mesh the main mesh to create the submesh from
  81717. * @param renderingMesh the optional rendering mesh
  81718. * @returns a new submesh
  81719. */
  81720. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  81721. }
  81722. }
  81723. declare module BABYLON {
  81724. /**
  81725. * Class used to store geometry data (vertex buffers + index buffer)
  81726. */
  81727. export class Geometry implements IGetSetVerticesData {
  81728. /**
  81729. * Gets or sets the ID of the geometry
  81730. */
  81731. id: string;
  81732. /**
  81733. * Gets or sets the unique ID of the geometry
  81734. */
  81735. uniqueId: number;
  81736. /**
  81737. * Gets the delay loading state of the geometry (none by default which means not delayed)
  81738. */
  81739. delayLoadState: number;
  81740. /**
  81741. * Gets the file containing the data to load when running in delay load state
  81742. */
  81743. delayLoadingFile: Nullable<string>;
  81744. /**
  81745. * Callback called when the geometry is updated
  81746. */
  81747. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  81748. private _scene;
  81749. private _engine;
  81750. private _meshes;
  81751. private _totalVertices;
  81752. /** @hidden */
  81753. _indices: IndicesArray;
  81754. /** @hidden */
  81755. _vertexBuffers: {
  81756. [key: string]: VertexBuffer;
  81757. };
  81758. private _isDisposed;
  81759. private _extend;
  81760. private _boundingBias;
  81761. /** @hidden */
  81762. _delayInfo: Array<string>;
  81763. private _indexBuffer;
  81764. private _indexBufferIsUpdatable;
  81765. /** @hidden */
  81766. _boundingInfo: Nullable<BoundingInfo>;
  81767. /** @hidden */
  81768. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  81769. /** @hidden */
  81770. _softwareSkinningFrameId: number;
  81771. private _vertexArrayObjects;
  81772. private _updatable;
  81773. /** @hidden */
  81774. _positions: Nullable<Vector3[]>;
  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. /**
  81779. * 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
  81780. */
  81781. boundingBias: Vector2;
  81782. /**
  81783. * Static function used to attach a new empty geometry to a mesh
  81784. * @param mesh defines the mesh to attach the geometry to
  81785. * @returns the new Geometry
  81786. */
  81787. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  81788. /**
  81789. * Creates a new geometry
  81790. * @param id defines the unique ID
  81791. * @param scene defines the hosting scene
  81792. * @param vertexData defines the VertexData used to get geometry data
  81793. * @param updatable defines if geometry must be updatable (false by default)
  81794. * @param mesh defines the mesh that will be associated with the geometry
  81795. */
  81796. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  81797. /**
  81798. * Gets the current extend of the geometry
  81799. */
  81800. readonly extend: {
  81801. minimum: Vector3;
  81802. maximum: Vector3;
  81803. };
  81804. /**
  81805. * Gets the hosting scene
  81806. * @returns the hosting Scene
  81807. */
  81808. getScene(): Scene;
  81809. /**
  81810. * Gets the hosting engine
  81811. * @returns the hosting Engine
  81812. */
  81813. getEngine(): Engine;
  81814. /**
  81815. * Defines if the geometry is ready to use
  81816. * @returns true if the geometry is ready to be used
  81817. */
  81818. isReady(): boolean;
  81819. /**
  81820. * Gets a value indicating that the geometry should not be serialized
  81821. */
  81822. readonly doNotSerialize: boolean;
  81823. /** @hidden */
  81824. _rebuild(): void;
  81825. /**
  81826. * Affects all geometry data in one call
  81827. * @param vertexData defines the geometry data
  81828. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  81829. */
  81830. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  81831. /**
  81832. * Set specific vertex data
  81833. * @param kind defines the data kind (Position, normal, etc...)
  81834. * @param data defines the vertex data to use
  81835. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  81836. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  81837. */
  81838. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  81839. /**
  81840. * Removes a specific vertex data
  81841. * @param kind defines the data kind (Position, normal, etc...)
  81842. */
  81843. removeVerticesData(kind: string): void;
  81844. /**
  81845. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  81846. * @param buffer defines the vertex buffer to use
  81847. * @param totalVertices defines the total number of vertices for position kind (could be null)
  81848. */
  81849. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  81850. /**
  81851. * Update a specific vertex buffer
  81852. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  81853. * It will do nothing if the buffer is not updatable
  81854. * @param kind defines the data kind (Position, normal, etc...)
  81855. * @param data defines the data to use
  81856. * @param offset defines the offset in the target buffer where to store the data
  81857. * @param useBytes set to true if the offset is in bytes
  81858. */
  81859. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  81860. /**
  81861. * Update a specific vertex buffer
  81862. * This function will create a new buffer if the current one is not updatable
  81863. * @param kind defines the data kind (Position, normal, etc...)
  81864. * @param data defines the data to use
  81865. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  81866. */
  81867. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  81868. private _updateBoundingInfo;
  81869. /** @hidden */
  81870. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  81871. /**
  81872. * Gets total number of vertices
  81873. * @returns the total number of vertices
  81874. */
  81875. getTotalVertices(): number;
  81876. /**
  81877. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  81878. * @param kind defines the data kind (Position, normal, etc...)
  81879. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81880. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81881. * @returns a float array containing vertex data
  81882. */
  81883. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  81884. /**
  81885. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  81886. * @param kind defines the data kind (Position, normal, etc...)
  81887. * @returns true if the vertex buffer with the specified kind is updatable
  81888. */
  81889. isVertexBufferUpdatable(kind: string): boolean;
  81890. /**
  81891. * Gets a specific vertex buffer
  81892. * @param kind defines the data kind (Position, normal, etc...)
  81893. * @returns a VertexBuffer
  81894. */
  81895. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  81896. /**
  81897. * Returns all vertex buffers
  81898. * @return an object holding all vertex buffers indexed by kind
  81899. */
  81900. getVertexBuffers(): Nullable<{
  81901. [key: string]: VertexBuffer;
  81902. }>;
  81903. /**
  81904. * Gets a boolean indicating if specific vertex buffer is present
  81905. * @param kind defines the data kind (Position, normal, etc...)
  81906. * @returns true if data is present
  81907. */
  81908. isVerticesDataPresent(kind: string): boolean;
  81909. /**
  81910. * Gets a list of all attached data kinds (Position, normal, etc...)
  81911. * @returns a list of string containing all kinds
  81912. */
  81913. getVerticesDataKinds(): string[];
  81914. /**
  81915. * Update index buffer
  81916. * @param indices defines the indices to store in the index buffer
  81917. * @param offset defines the offset in the target buffer where to store the data
  81918. * @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)
  81919. */
  81920. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  81921. /**
  81922. * Creates a new index buffer
  81923. * @param indices defines the indices to store in the index buffer
  81924. * @param totalVertices defines the total number of vertices (could be null)
  81925. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  81926. */
  81927. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  81928. /**
  81929. * Return the total number of indices
  81930. * @returns the total number of indices
  81931. */
  81932. getTotalIndices(): number;
  81933. /**
  81934. * Gets the index buffer array
  81935. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  81936. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  81937. * @returns the index buffer array
  81938. */
  81939. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  81940. /**
  81941. * Gets the index buffer
  81942. * @return the index buffer
  81943. */
  81944. getIndexBuffer(): Nullable<WebGLBuffer>;
  81945. /** @hidden */
  81946. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  81947. /**
  81948. * Release the associated resources for a specific mesh
  81949. * @param mesh defines the source mesh
  81950. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  81951. */
  81952. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  81953. /**
  81954. * Apply current geometry to a given mesh
  81955. * @param mesh defines the mesh to apply geometry to
  81956. */
  81957. applyToMesh(mesh: Mesh): void;
  81958. private _updateExtend;
  81959. private _applyToMesh;
  81960. private notifyUpdate;
  81961. /**
  81962. * Load the geometry if it was flagged as delay loaded
  81963. * @param scene defines the hosting scene
  81964. * @param onLoaded defines a callback called when the geometry is loaded
  81965. */
  81966. load(scene: Scene, onLoaded?: () => void): void;
  81967. private _queueLoad;
  81968. /**
  81969. * Invert the geometry to move from a right handed system to a left handed one.
  81970. */
  81971. toLeftHanded(): void;
  81972. /** @hidden */
  81973. _resetPointsArrayCache(): void;
  81974. /** @hidden */
  81975. _generatePointsArray(): boolean;
  81976. /**
  81977. * Gets a value indicating if the geometry is disposed
  81978. * @returns true if the geometry was disposed
  81979. */
  81980. isDisposed(): boolean;
  81981. private _disposeVertexArrayObjects;
  81982. /**
  81983. * Free all associated resources
  81984. */
  81985. dispose(): void;
  81986. /**
  81987. * Clone the current geometry into a new geometry
  81988. * @param id defines the unique ID of the new geometry
  81989. * @returns a new geometry object
  81990. */
  81991. copy(id: string): Geometry;
  81992. /**
  81993. * Serialize the current geometry info (and not the vertices data) into a JSON object
  81994. * @return a JSON representation of the current geometry data (without the vertices data)
  81995. */
  81996. serialize(): any;
  81997. private toNumberArray;
  81998. /**
  81999. * Serialize all vertices data into a JSON oject
  82000. * @returns a JSON representation of the current geometry data
  82001. */
  82002. serializeVerticeData(): any;
  82003. /**
  82004. * Extracts a clone of a mesh geometry
  82005. * @param mesh defines the source mesh
  82006. * @param id defines the unique ID of the new geometry object
  82007. * @returns the new geometry object
  82008. */
  82009. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82010. /**
  82011. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82012. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82013. * Be aware Math.random() could cause collisions, but:
  82014. * "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"
  82015. * @returns a string containing a new GUID
  82016. */
  82017. static RandomId(): string;
  82018. /** @hidden */
  82019. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82020. private static _CleanMatricesWeights;
  82021. /**
  82022. * Create a new geometry from persisted data (Using .babylon file format)
  82023. * @param parsedVertexData defines the persisted data
  82024. * @param scene defines the hosting scene
  82025. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82026. * @returns the new geometry object
  82027. */
  82028. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82029. }
  82030. }
  82031. declare module BABYLON {
  82032. /**
  82033. * Define an interface for all classes that will get and set the data on vertices
  82034. */
  82035. export interface IGetSetVerticesData {
  82036. /**
  82037. * Gets a boolean indicating if specific vertex data is present
  82038. * @param kind defines the vertex data kind to use
  82039. * @returns true is data kind is present
  82040. */
  82041. isVerticesDataPresent(kind: string): boolean;
  82042. /**
  82043. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82044. * @param kind defines the data kind (Position, normal, etc...)
  82045. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82046. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82047. * @returns a float array containing vertex data
  82048. */
  82049. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82050. /**
  82051. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82052. * @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.
  82053. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82054. * @returns the indices array or an empty array if the mesh has no geometry
  82055. */
  82056. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82057. /**
  82058. * Set specific vertex data
  82059. * @param kind defines the data kind (Position, normal, etc...)
  82060. * @param data defines the vertex data to use
  82061. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82062. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82063. */
  82064. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82065. /**
  82066. * Update a specific associated vertex buffer
  82067. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82068. * - VertexBuffer.PositionKind
  82069. * - VertexBuffer.UVKind
  82070. * - VertexBuffer.UV2Kind
  82071. * - VertexBuffer.UV3Kind
  82072. * - VertexBuffer.UV4Kind
  82073. * - VertexBuffer.UV5Kind
  82074. * - VertexBuffer.UV6Kind
  82075. * - VertexBuffer.ColorKind
  82076. * - VertexBuffer.MatricesIndicesKind
  82077. * - VertexBuffer.MatricesIndicesExtraKind
  82078. * - VertexBuffer.MatricesWeightsKind
  82079. * - VertexBuffer.MatricesWeightsExtraKind
  82080. * @param data defines the data source
  82081. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82082. * @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)
  82083. */
  82084. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82085. /**
  82086. * Creates a new index buffer
  82087. * @param indices defines the indices to store in the index buffer
  82088. * @param totalVertices defines the total number of vertices (could be null)
  82089. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82090. */
  82091. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82092. }
  82093. /**
  82094. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82095. */
  82096. export class VertexData {
  82097. /**
  82098. * Mesh side orientation : usually the external or front surface
  82099. */
  82100. static readonly FRONTSIDE: number;
  82101. /**
  82102. * Mesh side orientation : usually the internal or back surface
  82103. */
  82104. static readonly BACKSIDE: number;
  82105. /**
  82106. * Mesh side orientation : both internal and external or front and back surfaces
  82107. */
  82108. static readonly DOUBLESIDE: number;
  82109. /**
  82110. * Mesh side orientation : by default, `FRONTSIDE`
  82111. */
  82112. static readonly DEFAULTSIDE: number;
  82113. /**
  82114. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82115. */
  82116. positions: Nullable<FloatArray>;
  82117. /**
  82118. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82119. */
  82120. normals: Nullable<FloatArray>;
  82121. /**
  82122. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82123. */
  82124. tangents: Nullable<FloatArray>;
  82125. /**
  82126. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82127. */
  82128. uvs: Nullable<FloatArray>;
  82129. /**
  82130. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82131. */
  82132. uvs2: Nullable<FloatArray>;
  82133. /**
  82134. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82135. */
  82136. uvs3: Nullable<FloatArray>;
  82137. /**
  82138. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82139. */
  82140. uvs4: Nullable<FloatArray>;
  82141. /**
  82142. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82143. */
  82144. uvs5: Nullable<FloatArray>;
  82145. /**
  82146. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82147. */
  82148. uvs6: Nullable<FloatArray>;
  82149. /**
  82150. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82151. */
  82152. colors: Nullable<FloatArray>;
  82153. /**
  82154. * 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).
  82155. */
  82156. matricesIndices: Nullable<FloatArray>;
  82157. /**
  82158. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82159. */
  82160. matricesWeights: Nullable<FloatArray>;
  82161. /**
  82162. * An array extending the number of possible indices
  82163. */
  82164. matricesIndicesExtra: Nullable<FloatArray>;
  82165. /**
  82166. * An array extending the number of possible weights when the number of indices is extended
  82167. */
  82168. matricesWeightsExtra: Nullable<FloatArray>;
  82169. /**
  82170. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82171. */
  82172. indices: Nullable<IndicesArray>;
  82173. /**
  82174. * Uses the passed data array to set the set the values for the specified kind of data
  82175. * @param data a linear array of floating numbers
  82176. * @param kind the type of data that is being set, eg positions, colors etc
  82177. */
  82178. set(data: FloatArray, kind: string): void;
  82179. /**
  82180. * Associates the vertexData to the passed Mesh.
  82181. * Sets it as updatable or not (default `false`)
  82182. * @param mesh the mesh the vertexData is applied to
  82183. * @param updatable when used and having the value true allows new data to update the vertexData
  82184. * @returns the VertexData
  82185. */
  82186. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82187. /**
  82188. * Associates the vertexData to the passed Geometry.
  82189. * Sets it as updatable or not (default `false`)
  82190. * @param geometry the geometry the vertexData is applied to
  82191. * @param updatable when used and having the value true allows new data to update the vertexData
  82192. * @returns VertexData
  82193. */
  82194. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82195. /**
  82196. * Updates the associated mesh
  82197. * @param mesh the mesh to be updated
  82198. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82199. * @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
  82200. * @returns VertexData
  82201. */
  82202. updateMesh(mesh: Mesh): VertexData;
  82203. /**
  82204. * Updates the associated geometry
  82205. * @param geometry the geometry to be updated
  82206. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82207. * @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
  82208. * @returns VertexData.
  82209. */
  82210. updateGeometry(geometry: Geometry): VertexData;
  82211. private _applyTo;
  82212. private _update;
  82213. /**
  82214. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82215. * @param matrix the transforming matrix
  82216. * @returns the VertexData
  82217. */
  82218. transform(matrix: Matrix): VertexData;
  82219. /**
  82220. * Merges the passed VertexData into the current one
  82221. * @param other the VertexData to be merged into the current one
  82222. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82223. * @returns the modified VertexData
  82224. */
  82225. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82226. private _mergeElement;
  82227. private _validate;
  82228. /**
  82229. * Serializes the VertexData
  82230. * @returns a serialized object
  82231. */
  82232. serialize(): any;
  82233. /**
  82234. * Extracts the vertexData from a mesh
  82235. * @param mesh the mesh from which to extract the VertexData
  82236. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82237. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82238. * @returns the object VertexData associated to the passed mesh
  82239. */
  82240. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82241. /**
  82242. * Extracts the vertexData from the geometry
  82243. * @param geometry the geometry from which to extract the VertexData
  82244. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82245. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82246. * @returns the object VertexData associated to the passed mesh
  82247. */
  82248. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82249. private static _ExtractFrom;
  82250. /**
  82251. * Creates the VertexData for a Ribbon
  82252. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82253. * * pathArray array of paths, each of which an array of successive Vector3
  82254. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82255. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82256. * * 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
  82257. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82258. * * 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)
  82259. * * 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)
  82260. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82261. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82262. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82263. * @returns the VertexData of the ribbon
  82264. */
  82265. static CreateRibbon(options: {
  82266. pathArray: Vector3[][];
  82267. closeArray?: boolean;
  82268. closePath?: boolean;
  82269. offset?: number;
  82270. sideOrientation?: number;
  82271. frontUVs?: Vector4;
  82272. backUVs?: Vector4;
  82273. invertUV?: boolean;
  82274. uvs?: Vector2[];
  82275. colors?: Color4[];
  82276. }): VertexData;
  82277. /**
  82278. * Creates the VertexData for a box
  82279. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82280. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82281. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82282. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82283. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82284. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82285. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82286. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82287. * * 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)
  82288. * * 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)
  82289. * @returns the VertexData of the box
  82290. */
  82291. static CreateBox(options: {
  82292. size?: number;
  82293. width?: number;
  82294. height?: number;
  82295. depth?: number;
  82296. faceUV?: Vector4[];
  82297. faceColors?: Color4[];
  82298. sideOrientation?: number;
  82299. frontUVs?: Vector4;
  82300. backUVs?: Vector4;
  82301. }): VertexData;
  82302. /**
  82303. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82304. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82305. * * segments sets the number of horizontal strips optional, default 32
  82306. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82307. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82308. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82309. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82310. * * 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
  82311. * * 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
  82312. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82313. * * 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)
  82314. * * 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)
  82315. * @returns the VertexData of the ellipsoid
  82316. */
  82317. static CreateSphere(options: {
  82318. segments?: number;
  82319. diameter?: number;
  82320. diameterX?: number;
  82321. diameterY?: number;
  82322. diameterZ?: number;
  82323. arc?: number;
  82324. slice?: number;
  82325. sideOrientation?: number;
  82326. frontUVs?: Vector4;
  82327. backUVs?: Vector4;
  82328. }): VertexData;
  82329. /**
  82330. * Creates the VertexData for a cylinder, cone or prism
  82331. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82332. * * height sets the height (y direction) of the cylinder, optional, default 2
  82333. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82334. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82335. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82336. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82337. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82338. * * 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
  82339. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82340. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82341. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82342. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82343. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82344. * * 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)
  82345. * * 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)
  82346. * @returns the VertexData of the cylinder, cone or prism
  82347. */
  82348. static CreateCylinder(options: {
  82349. height?: number;
  82350. diameterTop?: number;
  82351. diameterBottom?: number;
  82352. diameter?: number;
  82353. tessellation?: number;
  82354. subdivisions?: number;
  82355. arc?: number;
  82356. faceColors?: Color4[];
  82357. faceUV?: Vector4[];
  82358. hasRings?: boolean;
  82359. enclose?: boolean;
  82360. sideOrientation?: number;
  82361. frontUVs?: Vector4;
  82362. backUVs?: Vector4;
  82363. }): VertexData;
  82364. /**
  82365. * Creates the VertexData for a torus
  82366. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82367. * * diameter the diameter of the torus, optional default 1
  82368. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82369. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82370. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82371. * * 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)
  82372. * * 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)
  82373. * @returns the VertexData of the torus
  82374. */
  82375. static CreateTorus(options: {
  82376. diameter?: number;
  82377. thickness?: number;
  82378. tessellation?: number;
  82379. sideOrientation?: number;
  82380. frontUVs?: Vector4;
  82381. backUVs?: Vector4;
  82382. }): VertexData;
  82383. /**
  82384. * Creates the VertexData of the LineSystem
  82385. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82386. * - lines an array of lines, each line being an array of successive Vector3
  82387. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82388. * @returns the VertexData of the LineSystem
  82389. */
  82390. static CreateLineSystem(options: {
  82391. lines: Vector3[][];
  82392. colors?: Nullable<Color4[][]>;
  82393. }): VertexData;
  82394. /**
  82395. * Create the VertexData for a DashedLines
  82396. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82397. * - points an array successive Vector3
  82398. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82399. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82400. * - dashNb the intended total number of dashes, optional, default 200
  82401. * @returns the VertexData for the DashedLines
  82402. */
  82403. static CreateDashedLines(options: {
  82404. points: Vector3[];
  82405. dashSize?: number;
  82406. gapSize?: number;
  82407. dashNb?: number;
  82408. }): VertexData;
  82409. /**
  82410. * Creates the VertexData for a Ground
  82411. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82412. * - width the width (x direction) of the ground, optional, default 1
  82413. * - height the height (z direction) of the ground, optional, default 1
  82414. * - subdivisions the number of subdivisions per side, optional, default 1
  82415. * @returns the VertexData of the Ground
  82416. */
  82417. static CreateGround(options: {
  82418. width?: number;
  82419. height?: number;
  82420. subdivisions?: number;
  82421. subdivisionsX?: number;
  82422. subdivisionsY?: number;
  82423. }): VertexData;
  82424. /**
  82425. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82426. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82427. * * xmin the ground minimum X coordinate, optional, default -1
  82428. * * zmin the ground minimum Z coordinate, optional, default -1
  82429. * * xmax the ground maximum X coordinate, optional, default 1
  82430. * * zmax the ground maximum Z coordinate, optional, default 1
  82431. * * 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}
  82432. * * 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}
  82433. * @returns the VertexData of the TiledGround
  82434. */
  82435. static CreateTiledGround(options: {
  82436. xmin: number;
  82437. zmin: number;
  82438. xmax: number;
  82439. zmax: number;
  82440. subdivisions?: {
  82441. w: number;
  82442. h: number;
  82443. };
  82444. precision?: {
  82445. w: number;
  82446. h: number;
  82447. };
  82448. }): VertexData;
  82449. /**
  82450. * Creates the VertexData of the Ground designed from a heightmap
  82451. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82452. * * width the width (x direction) of the ground
  82453. * * height the height (z direction) of the ground
  82454. * * subdivisions the number of subdivisions per side
  82455. * * minHeight the minimum altitude on the ground, optional, default 0
  82456. * * maxHeight the maximum altitude on the ground, optional default 1
  82457. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82458. * * buffer the array holding the image color data
  82459. * * bufferWidth the width of image
  82460. * * bufferHeight the height of image
  82461. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82462. * @returns the VertexData of the Ground designed from a heightmap
  82463. */
  82464. static CreateGroundFromHeightMap(options: {
  82465. width: number;
  82466. height: number;
  82467. subdivisions: number;
  82468. minHeight: number;
  82469. maxHeight: number;
  82470. colorFilter: Color3;
  82471. buffer: Uint8Array;
  82472. bufferWidth: number;
  82473. bufferHeight: number;
  82474. alphaFilter: number;
  82475. }): VertexData;
  82476. /**
  82477. * Creates the VertexData for a Plane
  82478. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82479. * * size sets the width and height of the plane to the value of size, optional default 1
  82480. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82481. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82482. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82483. * * 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)
  82484. * * 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)
  82485. * @returns the VertexData of the box
  82486. */
  82487. static CreatePlane(options: {
  82488. size?: number;
  82489. width?: number;
  82490. height?: number;
  82491. sideOrientation?: number;
  82492. frontUVs?: Vector4;
  82493. backUVs?: Vector4;
  82494. }): VertexData;
  82495. /**
  82496. * Creates the VertexData of the Disc or regular Polygon
  82497. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82498. * * radius the radius of the disc, optional default 0.5
  82499. * * tessellation the number of polygon sides, optional, default 64
  82500. * * 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
  82501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82502. * * 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)
  82503. * * 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)
  82504. * @returns the VertexData of the box
  82505. */
  82506. static CreateDisc(options: {
  82507. radius?: number;
  82508. tessellation?: number;
  82509. arc?: number;
  82510. sideOrientation?: number;
  82511. frontUVs?: Vector4;
  82512. backUVs?: Vector4;
  82513. }): VertexData;
  82514. /**
  82515. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82516. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82517. * @param polygon a mesh built from polygonTriangulation.build()
  82518. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82519. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82520. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82521. * @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)
  82522. * @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)
  82523. * @returns the VertexData of the Polygon
  82524. */
  82525. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82526. /**
  82527. * Creates the VertexData of the IcoSphere
  82528. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82529. * * radius the radius of the IcoSphere, optional default 1
  82530. * * radiusX allows stretching in the x direction, optional, default radius
  82531. * * radiusY allows stretching in the y direction, optional, default radius
  82532. * * radiusZ allows stretching in the z direction, optional, default radius
  82533. * * flat when true creates a flat shaded mesh, optional, default true
  82534. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82535. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82536. * * 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)
  82537. * * 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)
  82538. * @returns the VertexData of the IcoSphere
  82539. */
  82540. static CreateIcoSphere(options: {
  82541. radius?: number;
  82542. radiusX?: number;
  82543. radiusY?: number;
  82544. radiusZ?: number;
  82545. flat?: boolean;
  82546. subdivisions?: number;
  82547. sideOrientation?: number;
  82548. frontUVs?: Vector4;
  82549. backUVs?: Vector4;
  82550. }): VertexData;
  82551. /**
  82552. * Creates the VertexData for a Polyhedron
  82553. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82554. * * type provided types are:
  82555. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82556. * * 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)
  82557. * * size the size of the IcoSphere, optional default 1
  82558. * * sizeX allows stretching in the x direction, optional, default size
  82559. * * sizeY allows stretching in the y direction, optional, default size
  82560. * * sizeZ allows stretching in the z direction, optional, default size
  82561. * * 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
  82562. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82563. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82564. * * flat when true creates a flat shaded mesh, optional, default true
  82565. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82566. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82567. * * 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)
  82568. * * 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)
  82569. * @returns the VertexData of the Polyhedron
  82570. */
  82571. static CreatePolyhedron(options: {
  82572. type?: number;
  82573. size?: number;
  82574. sizeX?: number;
  82575. sizeY?: number;
  82576. sizeZ?: number;
  82577. custom?: any;
  82578. faceUV?: Vector4[];
  82579. faceColors?: Color4[];
  82580. flat?: boolean;
  82581. sideOrientation?: number;
  82582. frontUVs?: Vector4;
  82583. backUVs?: Vector4;
  82584. }): VertexData;
  82585. /**
  82586. * Creates the VertexData for a TorusKnot
  82587. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82588. * * radius the radius of the torus knot, optional, default 2
  82589. * * tube the thickness of the tube, optional, default 0.5
  82590. * * radialSegments the number of sides on each tube segments, optional, default 32
  82591. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82592. * * p the number of windings around the z axis, optional, default 2
  82593. * * q the number of windings around the x axis, optional, default 3
  82594. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82595. * * 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)
  82596. * * 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)
  82597. * @returns the VertexData of the Torus Knot
  82598. */
  82599. static CreateTorusKnot(options: {
  82600. radius?: number;
  82601. tube?: number;
  82602. radialSegments?: number;
  82603. tubularSegments?: number;
  82604. p?: number;
  82605. q?: number;
  82606. sideOrientation?: number;
  82607. frontUVs?: Vector4;
  82608. backUVs?: Vector4;
  82609. }): VertexData;
  82610. /**
  82611. * Compute normals for given positions and indices
  82612. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82613. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82614. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82615. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82616. * * facetNormals : optional array of facet normals (vector3)
  82617. * * facetPositions : optional array of facet positions (vector3)
  82618. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82619. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82620. * * bInfo : optional bounding info, required for facetPartitioning computation
  82621. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82622. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82623. * * useRightHandedSystem: optional boolean to for right handed system computation
  82624. * * depthSort : optional boolean to enable the facet depth sort computation
  82625. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82626. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82627. */
  82628. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82629. facetNormals?: any;
  82630. facetPositions?: any;
  82631. facetPartitioning?: any;
  82632. ratio?: number;
  82633. bInfo?: any;
  82634. bbSize?: Vector3;
  82635. subDiv?: any;
  82636. useRightHandedSystem?: boolean;
  82637. depthSort?: boolean;
  82638. distanceTo?: Vector3;
  82639. depthSortedFacets?: any;
  82640. }): void;
  82641. /** @hidden */
  82642. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82643. /**
  82644. * Applies VertexData created from the imported parameters to the geometry
  82645. * @param parsedVertexData the parsed data from an imported file
  82646. * @param geometry the geometry to apply the VertexData to
  82647. */
  82648. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82649. }
  82650. }
  82651. declare module BABYLON {
  82652. /**
  82653. * Class containing static functions to help procedurally build meshes
  82654. */
  82655. export class DiscBuilder {
  82656. /**
  82657. * Creates a plane polygonal mesh. By default, this is a disc
  82658. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82659. * * 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
  82660. * * 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
  82661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82664. * @param name defines the name of the mesh
  82665. * @param options defines the options used to create the mesh
  82666. * @param scene defines the hosting scene
  82667. * @returns the plane polygonal mesh
  82668. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82669. */
  82670. static CreateDisc(name: string, options: {
  82671. radius?: number;
  82672. tessellation?: number;
  82673. arc?: number;
  82674. updatable?: boolean;
  82675. sideOrientation?: number;
  82676. frontUVs?: Vector4;
  82677. backUVs?: Vector4;
  82678. }, scene?: Nullable<Scene>): Mesh;
  82679. }
  82680. }
  82681. declare module BABYLON {
  82682. /**
  82683. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82684. *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.
  82685. * The SPS is also a particle system. It provides some methods to manage the particles.
  82686. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82687. *
  82688. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82689. */
  82690. export class SolidParticleSystem implements IDisposable {
  82691. /**
  82692. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82693. * Example : var p = SPS.particles[i];
  82694. */
  82695. particles: SolidParticle[];
  82696. /**
  82697. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82698. */
  82699. nbParticles: number;
  82700. /**
  82701. * If the particles must ever face the camera (default false). Useful for planar particles.
  82702. */
  82703. billboard: boolean;
  82704. /**
  82705. * Recompute normals when adding a shape
  82706. */
  82707. recomputeNormals: boolean;
  82708. /**
  82709. * This a counter ofr your own usage. It's not set by any SPS functions.
  82710. */
  82711. counter: number;
  82712. /**
  82713. * The SPS name. This name is also given to the underlying mesh.
  82714. */
  82715. name: string;
  82716. /**
  82717. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  82718. */
  82719. mesh: Mesh;
  82720. /**
  82721. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  82722. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  82723. */
  82724. vars: any;
  82725. /**
  82726. * This array is populated when the SPS is set as 'pickable'.
  82727. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  82728. * Each element of this array is an object `{idx: int, faceId: int}`.
  82729. * `idx` is the picked particle index in the `SPS.particles` array
  82730. * `faceId` is the picked face index counted within this particle.
  82731. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  82732. */
  82733. pickedParticles: {
  82734. idx: number;
  82735. faceId: number;
  82736. }[];
  82737. /**
  82738. * This array is populated when `enableDepthSort` is set to true.
  82739. * Each element of this array is an instance of the class DepthSortedParticle.
  82740. */
  82741. depthSortedParticles: DepthSortedParticle[];
  82742. /**
  82743. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  82744. * @hidden
  82745. */
  82746. _bSphereOnly: boolean;
  82747. /**
  82748. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  82749. * @hidden
  82750. */
  82751. _bSphereRadiusFactor: number;
  82752. private _scene;
  82753. private _positions;
  82754. private _indices;
  82755. private _normals;
  82756. private _colors;
  82757. private _uvs;
  82758. private _indices32;
  82759. private _positions32;
  82760. private _normals32;
  82761. private _fixedNormal32;
  82762. private _colors32;
  82763. private _uvs32;
  82764. private _index;
  82765. private _updatable;
  82766. private _pickable;
  82767. private _isVisibilityBoxLocked;
  82768. private _alwaysVisible;
  82769. private _depthSort;
  82770. private _shapeCounter;
  82771. private _copy;
  82772. private _color;
  82773. private _computeParticleColor;
  82774. private _computeParticleTexture;
  82775. private _computeParticleRotation;
  82776. private _computeParticleVertex;
  82777. private _computeBoundingBox;
  82778. private _depthSortParticles;
  82779. private _camera;
  82780. private _mustUnrotateFixedNormals;
  82781. private _particlesIntersect;
  82782. private _needs32Bits;
  82783. /**
  82784. * Creates a SPS (Solid Particle System) object.
  82785. * @param name (String) is the SPS name, this will be the underlying mesh name.
  82786. * @param scene (Scene) is the scene in which the SPS is added.
  82787. * @param options defines the options of the sps e.g.
  82788. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  82789. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  82790. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  82791. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  82792. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  82793. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  82794. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  82795. */
  82796. constructor(name: string, scene: Scene, options?: {
  82797. updatable?: boolean;
  82798. isPickable?: boolean;
  82799. enableDepthSort?: boolean;
  82800. particleIntersection?: boolean;
  82801. boundingSphereOnly?: boolean;
  82802. bSphereRadiusFactor?: number;
  82803. });
  82804. /**
  82805. * Builds the SPS underlying mesh. Returns a standard Mesh.
  82806. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  82807. * @returns the created mesh
  82808. */
  82809. buildMesh(): Mesh;
  82810. /**
  82811. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  82812. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  82813. * Thus the particles generated from `digest()` have their property `position` set yet.
  82814. * @param mesh ( Mesh ) is the mesh to be digested
  82815. * @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
  82816. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  82817. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  82818. * @returns the current SPS
  82819. */
  82820. digest(mesh: Mesh, options?: {
  82821. facetNb?: number;
  82822. number?: number;
  82823. delta?: number;
  82824. }): SolidParticleSystem;
  82825. private _unrotateFixedNormals;
  82826. private _resetCopy;
  82827. private _meshBuilder;
  82828. private _posToShape;
  82829. private _uvsToShapeUV;
  82830. private _addParticle;
  82831. /**
  82832. * Adds some particles to the SPS from the model shape. Returns the shape id.
  82833. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  82834. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  82835. * @param nb (positive integer) the number of particles to be created from this model
  82836. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  82837. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  82838. * @returns the number of shapes in the system
  82839. */
  82840. addShape(mesh: Mesh, nb: number, options?: {
  82841. positionFunction?: any;
  82842. vertexFunction?: any;
  82843. }): number;
  82844. private _rebuildParticle;
  82845. /**
  82846. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  82847. * @returns the SPS.
  82848. */
  82849. rebuildMesh(): SolidParticleSystem;
  82850. /**
  82851. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  82852. * This method calls `updateParticle()` for each particle of the SPS.
  82853. * For an animated SPS, it is usually called within the render loop.
  82854. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  82855. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  82856. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  82857. * @returns the SPS.
  82858. */
  82859. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  82860. /**
  82861. * Disposes the SPS.
  82862. */
  82863. dispose(): void;
  82864. /**
  82865. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  82866. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82867. * @returns the SPS.
  82868. */
  82869. refreshVisibleSize(): SolidParticleSystem;
  82870. /**
  82871. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  82872. * @param size the size (float) of the visibility box
  82873. * note : this doesn't lock the SPS mesh bounding box.
  82874. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82875. */
  82876. setVisibilityBox(size: number): void;
  82877. /**
  82878. * Gets whether the SPS as always visible or not
  82879. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82880. */
  82881. /**
  82882. * Sets the SPS as always visible or not
  82883. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82884. */
  82885. isAlwaysVisible: boolean;
  82886. /**
  82887. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82888. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82889. */
  82890. /**
  82891. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  82892. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  82893. */
  82894. isVisibilityBoxLocked: boolean;
  82895. /**
  82896. * Tells to `setParticles()` to compute the particle rotations or not.
  82897. * Default value : true. The SPS is faster when it's set to false.
  82898. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82899. */
  82900. /**
  82901. * Gets if `setParticles()` computes the particle rotations or not.
  82902. * Default value : true. The SPS is faster when it's set to false.
  82903. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  82904. */
  82905. computeParticleRotation: boolean;
  82906. /**
  82907. * Tells to `setParticles()` to compute the particle colors or not.
  82908. * Default value : true. The SPS is faster when it's set to false.
  82909. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82910. */
  82911. /**
  82912. * Gets if `setParticles()` computes the particle colors or not.
  82913. * Default value : true. The SPS is faster when it's set to false.
  82914. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  82915. */
  82916. computeParticleColor: boolean;
  82917. /**
  82918. * Gets if `setParticles()` computes the particle textures or not.
  82919. * Default value : true. The SPS is faster when it's set to false.
  82920. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  82921. */
  82922. computeParticleTexture: boolean;
  82923. /**
  82924. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  82925. * Default value : false. The SPS is faster when it's set to false.
  82926. * Note : the particle custom vertex positions aren't stored values.
  82927. */
  82928. /**
  82929. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  82930. * Default value : false. The SPS is faster when it's set to false.
  82931. * Note : the particle custom vertex positions aren't stored values.
  82932. */
  82933. computeParticleVertex: boolean;
  82934. /**
  82935. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  82936. */
  82937. /**
  82938. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  82939. */
  82940. computeBoundingBox: boolean;
  82941. /**
  82942. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  82943. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82944. * Default : `true`
  82945. */
  82946. /**
  82947. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  82948. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  82949. * Default : `true`
  82950. */
  82951. depthSortParticles: boolean;
  82952. /**
  82953. * This function does nothing. It may be overwritten to set all the particle first values.
  82954. * The SPS doesn't call this function, you may have to call it by your own.
  82955. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82956. */
  82957. initParticles(): void;
  82958. /**
  82959. * This function does nothing. It may be overwritten to recycle a particle.
  82960. * The SPS doesn't call this function, you may have to call it by your own.
  82961. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82962. * @param particle The particle to recycle
  82963. * @returns the recycled particle
  82964. */
  82965. recycleParticle(particle: SolidParticle): SolidParticle;
  82966. /**
  82967. * Updates a particle : this function should be overwritten by the user.
  82968. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  82969. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  82970. * @example : just set a particle position or velocity and recycle conditions
  82971. * @param particle The particle to update
  82972. * @returns the updated particle
  82973. */
  82974. updateParticle(particle: SolidParticle): SolidParticle;
  82975. /**
  82976. * Updates a vertex of a particle : it can be overwritten by the user.
  82977. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  82978. * @param particle the current particle
  82979. * @param vertex the current index of the current particle
  82980. * @param pt the index of the current vertex in the particle shape
  82981. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  82982. * @example : just set a vertex particle position
  82983. * @returns the updated vertex
  82984. */
  82985. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  82986. /**
  82987. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  82988. * This does nothing and may be overwritten by the user.
  82989. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82990. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82991. * @param update the boolean update value actually passed to setParticles()
  82992. */
  82993. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  82994. /**
  82995. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  82996. * This will be passed three parameters.
  82997. * This does nothing and may be overwritten by the user.
  82998. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  82999. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83000. * @param update the boolean update value actually passed to setParticles()
  83001. */
  83002. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83003. }
  83004. }
  83005. declare module BABYLON {
  83006. /**
  83007. * Represents one particle of a solid particle system.
  83008. */
  83009. export class SolidParticle {
  83010. /**
  83011. * particle global index
  83012. */
  83013. idx: number;
  83014. /**
  83015. * The color of the particle
  83016. */
  83017. color: Nullable<Color4>;
  83018. /**
  83019. * The world space position of the particle.
  83020. */
  83021. position: Vector3;
  83022. /**
  83023. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83024. */
  83025. rotation: Vector3;
  83026. /**
  83027. * The world space rotation quaternion of the particle.
  83028. */
  83029. rotationQuaternion: Nullable<Quaternion>;
  83030. /**
  83031. * The scaling of the particle.
  83032. */
  83033. scaling: Vector3;
  83034. /**
  83035. * The uvs of the particle.
  83036. */
  83037. uvs: Vector4;
  83038. /**
  83039. * The current speed of the particle.
  83040. */
  83041. velocity: Vector3;
  83042. /**
  83043. * The pivot point in the particle local space.
  83044. */
  83045. pivot: Vector3;
  83046. /**
  83047. * Must the particle be translated from its pivot point in its local space ?
  83048. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83049. * Default : false
  83050. */
  83051. translateFromPivot: boolean;
  83052. /**
  83053. * Is the particle active or not ?
  83054. */
  83055. alive: boolean;
  83056. /**
  83057. * Is the particle visible or not ?
  83058. */
  83059. isVisible: boolean;
  83060. /**
  83061. * Index of this particle in the global "positions" array (Internal use)
  83062. * @hidden
  83063. */
  83064. _pos: number;
  83065. /**
  83066. * @hidden Index of this particle in the global "indices" array (Internal use)
  83067. */
  83068. _ind: number;
  83069. /**
  83070. * @hidden ModelShape of this particle (Internal use)
  83071. */
  83072. _model: ModelShape;
  83073. /**
  83074. * ModelShape id of this particle
  83075. */
  83076. shapeId: number;
  83077. /**
  83078. * Index of the particle in its shape id (Internal use)
  83079. */
  83080. idxInShape: number;
  83081. /**
  83082. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83083. */
  83084. _modelBoundingInfo: BoundingInfo;
  83085. /**
  83086. * @hidden Particle BoundingInfo object (Internal use)
  83087. */
  83088. _boundingInfo: BoundingInfo;
  83089. /**
  83090. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83091. */
  83092. _sps: SolidParticleSystem;
  83093. /**
  83094. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83095. */
  83096. _stillInvisible: boolean;
  83097. /**
  83098. * @hidden Last computed particle rotation matrix
  83099. */
  83100. _rotationMatrix: number[];
  83101. /**
  83102. * Parent particle Id, if any.
  83103. * Default null.
  83104. */
  83105. parentId: Nullable<number>;
  83106. /**
  83107. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83108. * The possible values are :
  83109. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83110. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83111. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83112. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83113. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83114. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83115. * */
  83116. cullingStrategy: number;
  83117. /**
  83118. * @hidden Internal global position in the SPS.
  83119. */
  83120. _globalPosition: Vector3;
  83121. /**
  83122. * Creates a Solid Particle object.
  83123. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83124. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83125. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83126. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83127. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83128. * @param shapeId (integer) is the model shape identifier in the SPS.
  83129. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83130. * @param sps defines the sps it is associated to
  83131. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83132. */
  83133. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83134. /**
  83135. * Legacy support, changed scale to scaling
  83136. */
  83137. /**
  83138. * Legacy support, changed scale to scaling
  83139. */
  83140. scale: Vector3;
  83141. /**
  83142. * Legacy support, changed quaternion to rotationQuaternion
  83143. */
  83144. /**
  83145. * Legacy support, changed quaternion to rotationQuaternion
  83146. */
  83147. quaternion: Nullable<Quaternion>;
  83148. /**
  83149. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83150. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83151. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83152. * @returns true if it intersects
  83153. */
  83154. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83155. /**
  83156. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83157. * A particle is in the frustum if its bounding box intersects the frustum
  83158. * @param frustumPlanes defines the frustum to test
  83159. * @returns true if the particle is in the frustum planes
  83160. */
  83161. isInFrustum(frustumPlanes: Plane[]): boolean;
  83162. /**
  83163. * get the rotation matrix of the particle
  83164. * @hidden
  83165. */
  83166. getRotationMatrix(m: Matrix): void;
  83167. }
  83168. /**
  83169. * Represents the shape of the model used by one particle of a solid particle system.
  83170. * SPS internal tool, don't use it manually.
  83171. */
  83172. export class ModelShape {
  83173. /**
  83174. * The shape id
  83175. * @hidden
  83176. */
  83177. shapeID: number;
  83178. /**
  83179. * flat array of model positions (internal use)
  83180. * @hidden
  83181. */
  83182. _shape: Vector3[];
  83183. /**
  83184. * flat array of model UVs (internal use)
  83185. * @hidden
  83186. */
  83187. _shapeUV: number[];
  83188. /**
  83189. * length of the shape in the model indices array (internal use)
  83190. * @hidden
  83191. */
  83192. _indicesLength: number;
  83193. /**
  83194. * Custom position function (internal use)
  83195. * @hidden
  83196. */
  83197. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83198. /**
  83199. * Custom vertex function (internal use)
  83200. * @hidden
  83201. */
  83202. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83203. /**
  83204. * 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.
  83205. * SPS internal tool, don't use it manually.
  83206. * @hidden
  83207. */
  83208. 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>);
  83209. }
  83210. /**
  83211. * Represents a Depth Sorted Particle in the solid particle system.
  83212. */
  83213. export class DepthSortedParticle {
  83214. /**
  83215. * Index of the particle in the "indices" array
  83216. */
  83217. ind: number;
  83218. /**
  83219. * Length of the particle shape in the "indices" array
  83220. */
  83221. indicesLength: number;
  83222. /**
  83223. * Squared distance from the particle to the camera
  83224. */
  83225. sqDistance: number;
  83226. }
  83227. }
  83228. declare module BABYLON {
  83229. /**
  83230. * Class used to store all common mesh properties
  83231. */
  83232. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83233. /** No occlusion */
  83234. static OCCLUSION_TYPE_NONE: number;
  83235. /** Occlusion set to optimisitic */
  83236. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83237. /** Occlusion set to strict */
  83238. static OCCLUSION_TYPE_STRICT: number;
  83239. /** Use an accurante occlusion algorithm */
  83240. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83241. /** Use a conservative occlusion algorithm */
  83242. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83243. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83244. * Test order :
  83245. * Is the bounding sphere outside the frustum ?
  83246. * If not, are the bounding box vertices outside the frustum ?
  83247. * It not, then the cullable object is in the frustum.
  83248. */
  83249. static readonly CULLINGSTRATEGY_STANDARD: number;
  83250. /** Culling strategy : Bounding Sphere Only.
  83251. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83252. * It's also less accurate than the standard because some not visible objects can still be selected.
  83253. * Test : is the bounding sphere outside the frustum ?
  83254. * If not, then the cullable object is in the frustum.
  83255. */
  83256. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83257. /** Culling strategy : Optimistic Inclusion.
  83258. * This in an inclusion test first, then the standard exclusion test.
  83259. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83260. * 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.
  83261. * Anyway, it's as accurate as the standard strategy.
  83262. * Test :
  83263. * Is the cullable object bounding sphere center in the frustum ?
  83264. * If not, apply the default culling strategy.
  83265. */
  83266. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83267. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83268. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83269. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83270. * 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.
  83271. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83272. * Test :
  83273. * Is the cullable object bounding sphere center in the frustum ?
  83274. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83275. */
  83276. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83277. /**
  83278. * No billboard
  83279. */
  83280. static readonly BILLBOARDMODE_NONE: number;
  83281. /** Billboard on X axis */
  83282. static readonly BILLBOARDMODE_X: number;
  83283. /** Billboard on Y axis */
  83284. static readonly BILLBOARDMODE_Y: number;
  83285. /** Billboard on Z axis */
  83286. static readonly BILLBOARDMODE_Z: number;
  83287. /** Billboard on all axes */
  83288. static readonly BILLBOARDMODE_ALL: number;
  83289. private _facetData;
  83290. /**
  83291. * The culling strategy to use to check whether the mesh must be rendered or not.
  83292. * This value can be changed at any time and will be used on the next render mesh selection.
  83293. * The possible values are :
  83294. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83295. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83296. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83297. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83298. * Please read each static variable documentation to get details about the culling process.
  83299. * */
  83300. cullingStrategy: number;
  83301. /**
  83302. * Gets the number of facets in the mesh
  83303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83304. */
  83305. readonly facetNb: number;
  83306. /**
  83307. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83309. */
  83310. partitioningSubdivisions: number;
  83311. /**
  83312. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83313. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83314. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83315. */
  83316. partitioningBBoxRatio: number;
  83317. /**
  83318. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83319. * Works only for updatable meshes.
  83320. * Doesn't work with multi-materials
  83321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83322. */
  83323. mustDepthSortFacets: boolean;
  83324. /**
  83325. * The location (Vector3) where the facet depth sort must be computed from.
  83326. * By default, the active camera position.
  83327. * Used only when facet depth sort is enabled
  83328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83329. */
  83330. facetDepthSortFrom: Vector3;
  83331. /**
  83332. * gets a boolean indicating if facetData is enabled
  83333. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83334. */
  83335. readonly isFacetDataEnabled: boolean;
  83336. /** @hidden */
  83337. _updateNonUniformScalingState(value: boolean): boolean;
  83338. /**
  83339. * An event triggered when this mesh collides with another one
  83340. */
  83341. onCollideObservable: Observable<AbstractMesh>;
  83342. private _onCollideObserver;
  83343. /** Set a function to call when this mesh collides with another one */
  83344. onCollide: () => void;
  83345. /**
  83346. * An event triggered when the collision's position changes
  83347. */
  83348. onCollisionPositionChangeObservable: Observable<Vector3>;
  83349. private _onCollisionPositionChangeObserver;
  83350. /** Set a function to call when the collision's position changes */
  83351. onCollisionPositionChange: () => void;
  83352. /**
  83353. * An event triggered when material is changed
  83354. */
  83355. onMaterialChangedObservable: Observable<AbstractMesh>;
  83356. /**
  83357. * Gets or sets the orientation for POV movement & rotation
  83358. */
  83359. definedFacingForward: boolean;
  83360. /** @hidden */
  83361. _occlusionQuery: Nullable<WebGLQuery>;
  83362. private _visibility;
  83363. /** @hidden */
  83364. _isActive: boolean;
  83365. /** @hidden */
  83366. _renderingGroup: Nullable<RenderingGroup>;
  83367. /**
  83368. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83369. */
  83370. /**
  83371. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83372. */
  83373. visibility: number;
  83374. /** Gets or sets the alpha index used to sort transparent meshes
  83375. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83376. */
  83377. alphaIndex: number;
  83378. /**
  83379. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83380. */
  83381. isVisible: boolean;
  83382. /**
  83383. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83384. */
  83385. isPickable: boolean;
  83386. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83387. showSubMeshesBoundingBox: boolean;
  83388. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83389. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83390. */
  83391. isBlocker: boolean;
  83392. /**
  83393. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83394. */
  83395. enablePointerMoveEvents: boolean;
  83396. /**
  83397. * Specifies the rendering group id for this mesh (0 by default)
  83398. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83399. */
  83400. renderingGroupId: number;
  83401. private _material;
  83402. /** Gets or sets current material */
  83403. material: Nullable<Material>;
  83404. private _receiveShadows;
  83405. /**
  83406. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83407. * @see http://doc.babylonjs.com/babylon101/shadows
  83408. */
  83409. receiveShadows: boolean;
  83410. /** Defines color to use when rendering outline */
  83411. outlineColor: Color3;
  83412. /** Define width to use when rendering outline */
  83413. outlineWidth: number;
  83414. /** Defines color to use when rendering overlay */
  83415. overlayColor: Color3;
  83416. /** Defines alpha to use when rendering overlay */
  83417. overlayAlpha: number;
  83418. private _hasVertexAlpha;
  83419. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83420. hasVertexAlpha: boolean;
  83421. private _useVertexColors;
  83422. /** 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) */
  83423. useVertexColors: boolean;
  83424. private _computeBonesUsingShaders;
  83425. /**
  83426. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83427. */
  83428. computeBonesUsingShaders: boolean;
  83429. private _numBoneInfluencers;
  83430. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83431. numBoneInfluencers: number;
  83432. private _applyFog;
  83433. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83434. applyFog: boolean;
  83435. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83436. useOctreeForRenderingSelection: boolean;
  83437. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83438. useOctreeForPicking: boolean;
  83439. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83440. useOctreeForCollisions: boolean;
  83441. private _layerMask;
  83442. /**
  83443. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83444. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83445. */
  83446. layerMask: number;
  83447. /**
  83448. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83449. */
  83450. alwaysSelectAsActiveMesh: boolean;
  83451. /**
  83452. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83453. */
  83454. doNotSyncBoundingInfo: boolean;
  83455. /**
  83456. * Gets or sets the current action manager
  83457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83458. */
  83459. actionManager: Nullable<AbstractActionManager>;
  83460. private _checkCollisions;
  83461. private _collisionMask;
  83462. private _collisionGroup;
  83463. /**
  83464. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83466. */
  83467. ellipsoid: Vector3;
  83468. /**
  83469. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83471. */
  83472. ellipsoidOffset: Vector3;
  83473. private _collider;
  83474. private _oldPositionForCollisions;
  83475. private _diffPositionForCollisions;
  83476. /**
  83477. * Gets or sets a collision mask used to mask collisions (default is -1).
  83478. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83479. */
  83480. collisionMask: number;
  83481. /**
  83482. * Gets or sets the current collision group mask (-1 by default).
  83483. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83484. */
  83485. collisionGroup: number;
  83486. /**
  83487. * Defines edge width used when edgesRenderer is enabled
  83488. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83489. */
  83490. edgesWidth: number;
  83491. /**
  83492. * Defines edge color used when edgesRenderer is enabled
  83493. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83494. */
  83495. edgesColor: Color4;
  83496. /** @hidden */
  83497. _edgesRenderer: Nullable<IEdgesRenderer>;
  83498. /** @hidden */
  83499. _masterMesh: Nullable<AbstractMesh>;
  83500. /** @hidden */
  83501. _boundingInfo: Nullable<BoundingInfo>;
  83502. /** @hidden */
  83503. _renderId: number;
  83504. /**
  83505. * Gets or sets the list of subMeshes
  83506. * @see http://doc.babylonjs.com/how_to/multi_materials
  83507. */
  83508. subMeshes: SubMesh[];
  83509. /** @hidden */
  83510. _intersectionsInProgress: AbstractMesh[];
  83511. /** @hidden */
  83512. _unIndexed: boolean;
  83513. /** @hidden */
  83514. _lightSources: Light[];
  83515. /** @hidden */
  83516. readonly _positions: Nullable<Vector3[]>;
  83517. /** @hidden */
  83518. _waitingActions: Nullable<any>;
  83519. /** @hidden */
  83520. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83521. private _skeleton;
  83522. /** @hidden */
  83523. _bonesTransformMatrices: Nullable<Float32Array>;
  83524. /**
  83525. * Gets or sets a skeleton to apply skining transformations
  83526. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83527. */
  83528. skeleton: Nullable<Skeleton>;
  83529. /**
  83530. * An event triggered when the mesh is rebuilt.
  83531. */
  83532. onRebuildObservable: Observable<AbstractMesh>;
  83533. /**
  83534. * Creates a new AbstractMesh
  83535. * @param name defines the name of the mesh
  83536. * @param scene defines the hosting scene
  83537. */
  83538. constructor(name: string, scene?: Nullable<Scene>);
  83539. /**
  83540. * Returns the string "AbstractMesh"
  83541. * @returns "AbstractMesh"
  83542. */
  83543. getClassName(): string;
  83544. /**
  83545. * Gets a string representation of the current mesh
  83546. * @param fullDetails defines a boolean indicating if full details must be included
  83547. * @returns a string representation of the current mesh
  83548. */
  83549. toString(fullDetails?: boolean): string;
  83550. /**
  83551. * @hidden
  83552. */
  83553. protected _getEffectiveParent(): Nullable<Node>;
  83554. /** @hidden */
  83555. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83556. /** @hidden */
  83557. _rebuild(): void;
  83558. /** @hidden */
  83559. _resyncLightSources(): void;
  83560. /** @hidden */
  83561. _resyncLighSource(light: Light): void;
  83562. /** @hidden */
  83563. _unBindEffect(): void;
  83564. /** @hidden */
  83565. _removeLightSource(light: Light): void;
  83566. private _markSubMeshesAsDirty;
  83567. /** @hidden */
  83568. _markSubMeshesAsLightDirty(): void;
  83569. /** @hidden */
  83570. _markSubMeshesAsAttributesDirty(): void;
  83571. /** @hidden */
  83572. _markSubMeshesAsMiscDirty(): void;
  83573. /**
  83574. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83575. */
  83576. scaling: Vector3;
  83577. /**
  83578. * Returns true if the mesh is blocked. Implemented by child classes
  83579. */
  83580. readonly isBlocked: boolean;
  83581. /**
  83582. * Returns the mesh itself by default. Implemented by child classes
  83583. * @param camera defines the camera to use to pick the right LOD level
  83584. * @returns the currentAbstractMesh
  83585. */
  83586. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83587. /**
  83588. * Returns 0 by default. Implemented by child classes
  83589. * @returns an integer
  83590. */
  83591. getTotalVertices(): number;
  83592. /**
  83593. * Returns a positive integer : the total number of indices in this mesh geometry.
  83594. * @returns the numner of indices or zero if the mesh has no geometry.
  83595. */
  83596. getTotalIndices(): number;
  83597. /**
  83598. * Returns null by default. Implemented by child classes
  83599. * @returns null
  83600. */
  83601. getIndices(): Nullable<IndicesArray>;
  83602. /**
  83603. * Returns the array of the requested vertex data kind. Implemented by child classes
  83604. * @param kind defines the vertex data kind to use
  83605. * @returns null
  83606. */
  83607. getVerticesData(kind: string): Nullable<FloatArray>;
  83608. /**
  83609. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83610. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83611. * Note that a new underlying VertexBuffer object is created each call.
  83612. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83613. * @param kind defines vertex data kind:
  83614. * * VertexBuffer.PositionKind
  83615. * * VertexBuffer.UVKind
  83616. * * VertexBuffer.UV2Kind
  83617. * * VertexBuffer.UV3Kind
  83618. * * VertexBuffer.UV4Kind
  83619. * * VertexBuffer.UV5Kind
  83620. * * VertexBuffer.UV6Kind
  83621. * * VertexBuffer.ColorKind
  83622. * * VertexBuffer.MatricesIndicesKind
  83623. * * VertexBuffer.MatricesIndicesExtraKind
  83624. * * VertexBuffer.MatricesWeightsKind
  83625. * * VertexBuffer.MatricesWeightsExtraKind
  83626. * @param data defines the data source
  83627. * @param updatable defines if the data must be flagged as updatable (or static)
  83628. * @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
  83629. * @returns the current mesh
  83630. */
  83631. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83632. /**
  83633. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83634. * If the mesh has no geometry, it is simply returned as it is.
  83635. * @param kind defines vertex data kind:
  83636. * * VertexBuffer.PositionKind
  83637. * * VertexBuffer.UVKind
  83638. * * VertexBuffer.UV2Kind
  83639. * * VertexBuffer.UV3Kind
  83640. * * VertexBuffer.UV4Kind
  83641. * * VertexBuffer.UV5Kind
  83642. * * VertexBuffer.UV6Kind
  83643. * * VertexBuffer.ColorKind
  83644. * * VertexBuffer.MatricesIndicesKind
  83645. * * VertexBuffer.MatricesIndicesExtraKind
  83646. * * VertexBuffer.MatricesWeightsKind
  83647. * * VertexBuffer.MatricesWeightsExtraKind
  83648. * @param data defines the data source
  83649. * @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
  83650. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83651. * @returns the current mesh
  83652. */
  83653. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83654. /**
  83655. * Sets the mesh indices,
  83656. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83657. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83658. * @param totalVertices Defines the total number of vertices
  83659. * @returns the current mesh
  83660. */
  83661. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83662. /**
  83663. * Gets a boolean indicating if specific vertex data is present
  83664. * @param kind defines the vertex data kind to use
  83665. * @returns true is data kind is present
  83666. */
  83667. isVerticesDataPresent(kind: string): boolean;
  83668. /**
  83669. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83670. * @returns a BoundingInfo
  83671. */
  83672. getBoundingInfo(): BoundingInfo;
  83673. /**
  83674. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83675. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83676. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83677. * @returns the current mesh
  83678. */
  83679. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83680. /**
  83681. * Overwrite the current bounding info
  83682. * @param boundingInfo defines the new bounding info
  83683. * @returns the current mesh
  83684. */
  83685. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83686. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83687. readonly useBones: boolean;
  83688. /** @hidden */
  83689. _preActivate(): void;
  83690. /** @hidden */
  83691. _preActivateForIntermediateRendering(renderId: number): void;
  83692. /** @hidden */
  83693. _activate(renderId: number): boolean;
  83694. /** @hidden */
  83695. _freeze(): void;
  83696. /** @hidden */
  83697. _unFreeze(): void;
  83698. /**
  83699. * Gets the current world matrix
  83700. * @returns a Matrix
  83701. */
  83702. getWorldMatrix(): Matrix;
  83703. /** @hidden */
  83704. _getWorldMatrixDeterminant(): number;
  83705. /**
  83706. * Perform relative position change from the point of view of behind the front of the mesh.
  83707. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83708. * Supports definition of mesh facing forward or backward
  83709. * @param amountRight defines the distance on the right axis
  83710. * @param amountUp defines the distance on the up axis
  83711. * @param amountForward defines the distance on the forward axis
  83712. * @returns the current mesh
  83713. */
  83714. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83715. /**
  83716. * Calculate relative position change from the point of view of behind the front of the mesh.
  83717. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83718. * Supports definition of mesh facing forward or backward
  83719. * @param amountRight defines the distance on the right axis
  83720. * @param amountUp defines the distance on the up axis
  83721. * @param amountForward defines the distance on the forward axis
  83722. * @returns the new displacement vector
  83723. */
  83724. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  83725. /**
  83726. * Perform relative rotation change from the point of view of behind the front of the mesh.
  83727. * Supports definition of mesh facing forward or backward
  83728. * @param flipBack defines the flip
  83729. * @param twirlClockwise defines the twirl
  83730. * @param tiltRight defines the tilt
  83731. * @returns the current mesh
  83732. */
  83733. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  83734. /**
  83735. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  83736. * Supports definition of mesh facing forward or backward.
  83737. * @param flipBack defines the flip
  83738. * @param twirlClockwise defines the twirl
  83739. * @param tiltRight defines the tilt
  83740. * @returns the new rotation vector
  83741. */
  83742. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  83743. /**
  83744. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83745. * This means the mesh underlying bounding box and sphere are recomputed.
  83746. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83747. * @returns the current mesh
  83748. */
  83749. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  83750. /** @hidden */
  83751. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  83752. /** @hidden */
  83753. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  83754. /** @hidden */
  83755. _updateBoundingInfo(): AbstractMesh;
  83756. /** @hidden */
  83757. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  83758. /** @hidden */
  83759. protected _afterComputeWorldMatrix(): void;
  83760. /** @hidden */
  83761. readonly _effectiveMesh: AbstractMesh;
  83762. /**
  83763. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83764. * A mesh is in the frustum if its bounding box intersects the frustum
  83765. * @param frustumPlanes defines the frustum to test
  83766. * @returns true if the mesh is in the frustum planes
  83767. */
  83768. isInFrustum(frustumPlanes: Plane[]): boolean;
  83769. /**
  83770. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  83771. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  83772. * @param frustumPlanes defines the frustum to test
  83773. * @returns true if the mesh is completely in the frustum planes
  83774. */
  83775. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  83776. /**
  83777. * True if the mesh intersects another mesh or a SolidParticle object
  83778. * @param mesh defines a target mesh or SolidParticle to test
  83779. * @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)
  83780. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  83781. * @returns true if there is an intersection
  83782. */
  83783. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  83784. /**
  83785. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  83786. * @param point defines the point to test
  83787. * @returns true if there is an intersection
  83788. */
  83789. intersectsPoint(point: Vector3): boolean;
  83790. /**
  83791. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  83792. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83793. */
  83794. checkCollisions: boolean;
  83795. /**
  83796. * Gets Collider object used to compute collisions (not physics)
  83797. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83798. */
  83799. readonly collider: Nullable<Collider>;
  83800. /**
  83801. * Move the mesh using collision engine
  83802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83803. * @param displacement defines the requested displacement vector
  83804. * @returns the current mesh
  83805. */
  83806. moveWithCollisions(displacement: Vector3): AbstractMesh;
  83807. private _onCollisionPositionChange;
  83808. /** @hidden */
  83809. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  83810. /** @hidden */
  83811. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  83812. /** @hidden */
  83813. _checkCollision(collider: Collider): AbstractMesh;
  83814. /** @hidden */
  83815. _generatePointsArray(): boolean;
  83816. /**
  83817. * Checks if the passed Ray intersects with the mesh
  83818. * @param ray defines the ray to use
  83819. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  83820. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  83821. * @returns the picking info
  83822. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  83823. */
  83824. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  83825. /**
  83826. * Clones the current mesh
  83827. * @param name defines the mesh name
  83828. * @param newParent defines the new mesh parent
  83829. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  83830. * @returns the new mesh
  83831. */
  83832. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  83833. /**
  83834. * Disposes all the submeshes of the current meshnp
  83835. * @returns the current mesh
  83836. */
  83837. releaseSubMeshes(): AbstractMesh;
  83838. /**
  83839. * Releases resources associated with this abstract mesh.
  83840. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83841. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83842. */
  83843. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83844. /**
  83845. * Adds the passed mesh as a child to the current mesh
  83846. * @param mesh defines the child mesh
  83847. * @returns the current mesh
  83848. */
  83849. addChild(mesh: AbstractMesh): AbstractMesh;
  83850. /**
  83851. * Removes the passed mesh from the current mesh children list
  83852. * @param mesh defines the child mesh
  83853. * @returns the current mesh
  83854. */
  83855. removeChild(mesh: AbstractMesh): AbstractMesh;
  83856. /** @hidden */
  83857. private _initFacetData;
  83858. /**
  83859. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  83860. * This method can be called within the render loop.
  83861. * 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
  83862. * @returns the current mesh
  83863. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83864. */
  83865. updateFacetData(): AbstractMesh;
  83866. /**
  83867. * Returns the facetLocalNormals array.
  83868. * The normals are expressed in the mesh local spac
  83869. * @returns an array of Vector3
  83870. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83871. */
  83872. getFacetLocalNormals(): Vector3[];
  83873. /**
  83874. * Returns the facetLocalPositions array.
  83875. * The facet positions are expressed in the mesh local space
  83876. * @returns an array of Vector3
  83877. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83878. */
  83879. getFacetLocalPositions(): Vector3[];
  83880. /**
  83881. * Returns the facetLocalPartioning array
  83882. * @returns an array of array of numbers
  83883. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83884. */
  83885. getFacetLocalPartitioning(): number[][];
  83886. /**
  83887. * Returns the i-th facet position in the world system.
  83888. * This method allocates a new Vector3 per call
  83889. * @param i defines the facet index
  83890. * @returns a new Vector3
  83891. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83892. */
  83893. getFacetPosition(i: number): Vector3;
  83894. /**
  83895. * Sets the reference Vector3 with the i-th facet position in the world system
  83896. * @param i defines the facet index
  83897. * @param ref defines the target vector
  83898. * @returns the current mesh
  83899. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83900. */
  83901. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  83902. /**
  83903. * Returns the i-th facet normal in the world system.
  83904. * This method allocates a new Vector3 per call
  83905. * @param i defines the facet index
  83906. * @returns a new Vector3
  83907. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83908. */
  83909. getFacetNormal(i: number): Vector3;
  83910. /**
  83911. * Sets the reference Vector3 with the i-th facet normal in the world system
  83912. * @param i defines the facet index
  83913. * @param ref defines the target vector
  83914. * @returns the current mesh
  83915. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83916. */
  83917. getFacetNormalToRef(i: number, ref: Vector3): this;
  83918. /**
  83919. * 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)
  83920. * @param x defines x coordinate
  83921. * @param y defines y coordinate
  83922. * @param z defines z coordinate
  83923. * @returns the array of facet indexes
  83924. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83925. */
  83926. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  83927. /**
  83928. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  83929. * @param projected sets as the (x,y,z) world projection on the facet
  83930. * @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
  83931. * @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
  83932. * @param x defines x coordinate
  83933. * @param y defines y coordinate
  83934. * @param z defines z coordinate
  83935. * @returns the face index if found (or null instead)
  83936. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83937. */
  83938. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83939. /**
  83940. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  83941. * @param projected sets as the (x,y,z) local projection on the facet
  83942. * @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
  83943. * @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
  83944. * @param x defines x coordinate
  83945. * @param y defines y coordinate
  83946. * @param z defines z coordinate
  83947. * @returns the face index if found (or null instead)
  83948. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83949. */
  83950. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  83951. /**
  83952. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  83953. * @returns the parameters
  83954. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83955. */
  83956. getFacetDataParameters(): any;
  83957. /**
  83958. * Disables the feature FacetData and frees the related memory
  83959. * @returns the current mesh
  83960. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  83961. */
  83962. disableFacetData(): AbstractMesh;
  83963. /**
  83964. * Updates the AbstractMesh indices array
  83965. * @param indices defines the data source
  83966. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83967. * @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)
  83968. * @returns the current mesh
  83969. */
  83970. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  83971. /**
  83972. * Creates new normals data for the mesh
  83973. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  83974. * @returns the current mesh
  83975. */
  83976. createNormals(updatable: boolean): AbstractMesh;
  83977. /**
  83978. * Align the mesh with a normal
  83979. * @param normal defines the normal to use
  83980. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  83981. * @returns the current mesh
  83982. */
  83983. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  83984. /** @hidden */
  83985. _checkOcclusionQuery(): boolean;
  83986. }
  83987. }
  83988. declare module BABYLON {
  83989. /**
  83990. * Interface used to define ActionEvent
  83991. */
  83992. export interface IActionEvent {
  83993. /** The mesh or sprite that triggered the action */
  83994. source: any;
  83995. /** The X mouse cursor position at the time of the event */
  83996. pointerX: number;
  83997. /** The Y mouse cursor position at the time of the event */
  83998. pointerY: number;
  83999. /** The mesh that is currently pointed at (can be null) */
  84000. meshUnderPointer: Nullable<AbstractMesh>;
  84001. /** the original (browser) event that triggered the ActionEvent */
  84002. sourceEvent?: any;
  84003. /** additional data for the event */
  84004. additionalData?: any;
  84005. }
  84006. /**
  84007. * ActionEvent is the event being sent when an action is triggered.
  84008. */
  84009. export class ActionEvent implements IActionEvent {
  84010. /** The mesh or sprite that triggered the action */
  84011. source: any;
  84012. /** The X mouse cursor position at the time of the event */
  84013. pointerX: number;
  84014. /** The Y mouse cursor position at the time of the event */
  84015. pointerY: number;
  84016. /** The mesh that is currently pointed at (can be null) */
  84017. meshUnderPointer: Nullable<AbstractMesh>;
  84018. /** the original (browser) event that triggered the ActionEvent */
  84019. sourceEvent?: any;
  84020. /** additional data for the event */
  84021. additionalData?: any;
  84022. /**
  84023. * Creates a new ActionEvent
  84024. * @param source The mesh or sprite that triggered the action
  84025. * @param pointerX The X mouse cursor position at the time of the event
  84026. * @param pointerY The Y mouse cursor position at the time of the event
  84027. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84028. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84029. * @param additionalData additional data for the event
  84030. */
  84031. constructor(
  84032. /** The mesh or sprite that triggered the action */
  84033. source: any,
  84034. /** The X mouse cursor position at the time of the event */
  84035. pointerX: number,
  84036. /** The Y mouse cursor position at the time of the event */
  84037. pointerY: number,
  84038. /** The mesh that is currently pointed at (can be null) */
  84039. meshUnderPointer: Nullable<AbstractMesh>,
  84040. /** the original (browser) event that triggered the ActionEvent */
  84041. sourceEvent?: any,
  84042. /** additional data for the event */
  84043. additionalData?: any);
  84044. /**
  84045. * Helper function to auto-create an ActionEvent from a source mesh.
  84046. * @param source The source mesh that triggered the event
  84047. * @param evt The original (browser) event
  84048. * @param additionalData additional data for the event
  84049. * @returns the new ActionEvent
  84050. */
  84051. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84052. /**
  84053. * Helper function to auto-create an ActionEvent from a source sprite
  84054. * @param source The source sprite that triggered the event
  84055. * @param scene Scene associated with the sprite
  84056. * @param evt The original (browser) event
  84057. * @param additionalData additional data for the event
  84058. * @returns the new ActionEvent
  84059. */
  84060. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84061. /**
  84062. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84063. * @param scene the scene where the event occurred
  84064. * @param evt The original (browser) event
  84065. * @returns the new ActionEvent
  84066. */
  84067. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84068. /**
  84069. * Helper function to auto-create an ActionEvent from a primitive
  84070. * @param prim defines the target primitive
  84071. * @param pointerPos defines the pointer position
  84072. * @param evt The original (browser) event
  84073. * @param additionalData additional data for the event
  84074. * @returns the new ActionEvent
  84075. */
  84076. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84077. }
  84078. }
  84079. declare module BABYLON {
  84080. /**
  84081. * Abstract class used to decouple action Manager from scene and meshes.
  84082. * Do not instantiate.
  84083. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84084. */
  84085. export abstract class AbstractActionManager implements IDisposable {
  84086. /** Gets the list of active triggers */
  84087. static Triggers: {
  84088. [key: string]: number;
  84089. };
  84090. /** Gets the cursor to use when hovering items */
  84091. hoverCursor: string;
  84092. /** Gets the list of actions */
  84093. actions: IAction[];
  84094. /**
  84095. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84096. */
  84097. isRecursive: boolean;
  84098. /**
  84099. * Releases all associated resources
  84100. */
  84101. abstract dispose(): void;
  84102. /**
  84103. * Does this action manager has pointer triggers
  84104. */
  84105. abstract readonly hasPointerTriggers: boolean;
  84106. /**
  84107. * Does this action manager has pick triggers
  84108. */
  84109. abstract readonly hasPickTriggers: boolean;
  84110. /**
  84111. * Process a specific trigger
  84112. * @param trigger defines the trigger to process
  84113. * @param evt defines the event details to be processed
  84114. */
  84115. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84116. /**
  84117. * Does this action manager handles actions of any of the given triggers
  84118. * @param triggers defines the triggers to be tested
  84119. * @return a boolean indicating whether one (or more) of the triggers is handled
  84120. */
  84121. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84122. /**
  84123. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84124. * speed.
  84125. * @param triggerA defines the trigger to be tested
  84126. * @param triggerB defines the trigger to be tested
  84127. * @return a boolean indicating whether one (or more) of the triggers is handled
  84128. */
  84129. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84130. /**
  84131. * Does this action manager handles actions of a given trigger
  84132. * @param trigger defines the trigger to be tested
  84133. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84134. * @return whether the trigger is handled
  84135. */
  84136. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84137. /**
  84138. * Serialize this manager to a JSON object
  84139. * @param name defines the property name to store this manager
  84140. * @returns a JSON representation of this manager
  84141. */
  84142. abstract serialize(name: string): any;
  84143. /**
  84144. * Registers an action to this action manager
  84145. * @param action defines the action to be registered
  84146. * @return the action amended (prepared) after registration
  84147. */
  84148. abstract registerAction(action: IAction): Nullable<IAction>;
  84149. /**
  84150. * Unregisters an action to this action manager
  84151. * @param action defines the action to be unregistered
  84152. * @return a boolean indicating whether the action has been unregistered
  84153. */
  84154. abstract unregisterAction(action: IAction): Boolean;
  84155. /**
  84156. * Does exist one action manager with at least one trigger
  84157. **/
  84158. static readonly HasTriggers: boolean;
  84159. /**
  84160. * Does exist one action manager with at least one pick trigger
  84161. **/
  84162. static readonly HasPickTriggers: boolean;
  84163. /**
  84164. * Does exist one action manager that handles actions of a given trigger
  84165. * @param trigger defines the trigger to be tested
  84166. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84167. **/
  84168. static HasSpecificTrigger(trigger: number): boolean;
  84169. }
  84170. }
  84171. declare module BABYLON {
  84172. /**
  84173. * Defines how a node can be built from a string name.
  84174. */
  84175. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84176. /**
  84177. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84178. */
  84179. export class Node implements IBehaviorAware<Node> {
  84180. /** @hidden */
  84181. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84182. private static _NodeConstructors;
  84183. /**
  84184. * Add a new node constructor
  84185. * @param type defines the type name of the node to construct
  84186. * @param constructorFunc defines the constructor function
  84187. */
  84188. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84189. /**
  84190. * Returns a node constructor based on type name
  84191. * @param type defines the type name
  84192. * @param name defines the new node name
  84193. * @param scene defines the hosting scene
  84194. * @param options defines optional options to transmit to constructors
  84195. * @returns the new constructor or null
  84196. */
  84197. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84198. /**
  84199. * Gets or sets the name of the node
  84200. */
  84201. name: string;
  84202. /**
  84203. * Gets or sets the id of the node
  84204. */
  84205. id: string;
  84206. /**
  84207. * Gets or sets the unique id of the node
  84208. */
  84209. uniqueId: number;
  84210. /**
  84211. * Gets or sets a string used to store user defined state for the node
  84212. */
  84213. state: string;
  84214. /**
  84215. * Gets or sets an object used to store user defined information for the node
  84216. */
  84217. metadata: any;
  84218. /**
  84219. * For internal use only. Please do not use.
  84220. */
  84221. reservedDataStore: any;
  84222. /**
  84223. * List of inspectable custom properties (used by the Inspector)
  84224. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84225. */
  84226. inspectableCustomProperties: IInspectable[];
  84227. /**
  84228. * Gets or sets a boolean used to define if the node must be serialized
  84229. */
  84230. doNotSerialize: boolean;
  84231. /** @hidden */
  84232. _isDisposed: boolean;
  84233. /**
  84234. * Gets a list of Animations associated with the node
  84235. */
  84236. animations: Animation[];
  84237. protected _ranges: {
  84238. [name: string]: Nullable<AnimationRange>;
  84239. };
  84240. /**
  84241. * Callback raised when the node is ready to be used
  84242. */
  84243. onReady: Nullable<(node: Node) => void>;
  84244. private _isEnabled;
  84245. private _isParentEnabled;
  84246. private _isReady;
  84247. /** @hidden */
  84248. _currentRenderId: number;
  84249. private _parentUpdateId;
  84250. /** @hidden */
  84251. _childUpdateId: number;
  84252. /** @hidden */
  84253. _waitingParentId: Nullable<string>;
  84254. /** @hidden */
  84255. _scene: Scene;
  84256. /** @hidden */
  84257. _cache: any;
  84258. private _parentNode;
  84259. private _children;
  84260. /** @hidden */
  84261. _worldMatrix: Matrix;
  84262. /** @hidden */
  84263. _worldMatrixDeterminant: number;
  84264. /** @hidden */
  84265. _worldMatrixDeterminantIsDirty: boolean;
  84266. /** @hidden */
  84267. private _sceneRootNodesIndex;
  84268. /**
  84269. * Gets a boolean indicating if the node has been disposed
  84270. * @returns true if the node was disposed
  84271. */
  84272. isDisposed(): boolean;
  84273. /**
  84274. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84275. * @see https://doc.babylonjs.com/how_to/parenting
  84276. */
  84277. parent: Nullable<Node>;
  84278. private addToSceneRootNodes;
  84279. private removeFromSceneRootNodes;
  84280. private _animationPropertiesOverride;
  84281. /**
  84282. * Gets or sets the animation properties override
  84283. */
  84284. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84285. /**
  84286. * Gets a string idenfifying the name of the class
  84287. * @returns "Node" string
  84288. */
  84289. getClassName(): string;
  84290. /** @hidden */
  84291. readonly _isNode: boolean;
  84292. /**
  84293. * An event triggered when the mesh is disposed
  84294. */
  84295. onDisposeObservable: Observable<Node>;
  84296. private _onDisposeObserver;
  84297. /**
  84298. * Sets a callback that will be raised when the node will be disposed
  84299. */
  84300. onDispose: () => void;
  84301. /**
  84302. * Creates a new Node
  84303. * @param name the name and id to be given to this node
  84304. * @param scene the scene this node will be added to
  84305. * @param addToRootNodes the node will be added to scene.rootNodes
  84306. */
  84307. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84308. /**
  84309. * Gets the scene of the node
  84310. * @returns a scene
  84311. */
  84312. getScene(): Scene;
  84313. /**
  84314. * Gets the engine of the node
  84315. * @returns a Engine
  84316. */
  84317. getEngine(): Engine;
  84318. private _behaviors;
  84319. /**
  84320. * Attach a behavior to the node
  84321. * @see http://doc.babylonjs.com/features/behaviour
  84322. * @param behavior defines the behavior to attach
  84323. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84324. * @returns the current Node
  84325. */
  84326. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84327. /**
  84328. * Remove an attached behavior
  84329. * @see http://doc.babylonjs.com/features/behaviour
  84330. * @param behavior defines the behavior to attach
  84331. * @returns the current Node
  84332. */
  84333. removeBehavior(behavior: Behavior<Node>): Node;
  84334. /**
  84335. * Gets the list of attached behaviors
  84336. * @see http://doc.babylonjs.com/features/behaviour
  84337. */
  84338. readonly behaviors: Behavior<Node>[];
  84339. /**
  84340. * Gets an attached behavior by name
  84341. * @param name defines the name of the behavior to look for
  84342. * @see http://doc.babylonjs.com/features/behaviour
  84343. * @returns null if behavior was not found else the requested behavior
  84344. */
  84345. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84346. /**
  84347. * Returns the latest update of the World matrix
  84348. * @returns a Matrix
  84349. */
  84350. getWorldMatrix(): Matrix;
  84351. /** @hidden */
  84352. _getWorldMatrixDeterminant(): number;
  84353. /**
  84354. * Returns directly the latest state of the mesh World matrix.
  84355. * A Matrix is returned.
  84356. */
  84357. readonly worldMatrixFromCache: Matrix;
  84358. /** @hidden */
  84359. _initCache(): void;
  84360. /** @hidden */
  84361. updateCache(force?: boolean): void;
  84362. /** @hidden */
  84363. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84364. /** @hidden */
  84365. _updateCache(ignoreParentClass?: boolean): void;
  84366. /** @hidden */
  84367. _isSynchronized(): boolean;
  84368. /** @hidden */
  84369. _markSyncedWithParent(): void;
  84370. /** @hidden */
  84371. isSynchronizedWithParent(): boolean;
  84372. /** @hidden */
  84373. isSynchronized(): boolean;
  84374. /**
  84375. * Is this node ready to be used/rendered
  84376. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84377. * @return true if the node is ready
  84378. */
  84379. isReady(completeCheck?: boolean): boolean;
  84380. /**
  84381. * Is this node enabled?
  84382. * 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
  84383. * @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
  84384. * @return whether this node (and its parent) is enabled
  84385. */
  84386. isEnabled(checkAncestors?: boolean): boolean;
  84387. /** @hidden */
  84388. protected _syncParentEnabledState(): void;
  84389. /**
  84390. * Set the enabled state of this node
  84391. * @param value defines the new enabled state
  84392. */
  84393. setEnabled(value: boolean): void;
  84394. /**
  84395. * Is this node a descendant of the given node?
  84396. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84397. * @param ancestor defines the parent node to inspect
  84398. * @returns a boolean indicating if this node is a descendant of the given node
  84399. */
  84400. isDescendantOf(ancestor: Node): boolean;
  84401. /** @hidden */
  84402. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84403. /**
  84404. * Will return all nodes that have this node as ascendant
  84405. * @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
  84406. * @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
  84407. * @return all children nodes of all types
  84408. */
  84409. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84410. /**
  84411. * Get all child-meshes of this node
  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 (Default: false)
  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. * @returns an array of AbstractMesh
  84415. */
  84416. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84417. /**
  84418. * Get all direct children of this node
  84419. * @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
  84420. * @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)
  84421. * @returns an array of Node
  84422. */
  84423. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84424. /** @hidden */
  84425. _setReady(state: boolean): void;
  84426. /**
  84427. * Get an animation by name
  84428. * @param name defines the name of the animation to look for
  84429. * @returns null if not found else the requested animation
  84430. */
  84431. getAnimationByName(name: string): Nullable<Animation>;
  84432. /**
  84433. * Creates an animation range for this node
  84434. * @param name defines the name of the range
  84435. * @param from defines the starting key
  84436. * @param to defines the end key
  84437. */
  84438. createAnimationRange(name: string, from: number, to: number): void;
  84439. /**
  84440. * Delete a specific animation range
  84441. * @param name defines the name of the range to delete
  84442. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84443. */
  84444. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84445. /**
  84446. * Get an animation range by name
  84447. * @param name defines the name of the animation range to look for
  84448. * @returns null if not found else the requested animation range
  84449. */
  84450. getAnimationRange(name: string): Nullable<AnimationRange>;
  84451. /**
  84452. * Gets the list of all animation ranges defined on this node
  84453. * @returns an array
  84454. */
  84455. getAnimationRanges(): Nullable<AnimationRange>[];
  84456. /**
  84457. * Will start the animation sequence
  84458. * @param name defines the range frames for animation sequence
  84459. * @param loop defines if the animation should loop (false by default)
  84460. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84461. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84462. * @returns the object created for this animation. If range does not exist, it will return null
  84463. */
  84464. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84465. /**
  84466. * Serialize animation ranges into a JSON compatible object
  84467. * @returns serialization object
  84468. */
  84469. serializeAnimationRanges(): any;
  84470. /**
  84471. * Computes the world matrix of the node
  84472. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84473. * @returns the world matrix
  84474. */
  84475. computeWorldMatrix(force?: boolean): Matrix;
  84476. /**
  84477. * Releases resources associated with this node.
  84478. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84479. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84480. */
  84481. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84482. /**
  84483. * Parse animation range data from a serialization object and store them into a given node
  84484. * @param node defines where to store the animation ranges
  84485. * @param parsedNode defines the serialization object to read data from
  84486. * @param scene defines the hosting scene
  84487. */
  84488. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84489. /**
  84490. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  84491. * @param includeDescendants Include bounding info from descendants as well (true by default)
  84492. * @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
  84493. * @returns the new bounding vectors
  84494. */
  84495. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  84496. min: Vector3;
  84497. max: Vector3;
  84498. };
  84499. }
  84500. }
  84501. declare module BABYLON {
  84502. /**
  84503. * @hidden
  84504. */
  84505. export class _IAnimationState {
  84506. key: number;
  84507. repeatCount: number;
  84508. workValue?: any;
  84509. loopMode?: number;
  84510. offsetValue?: any;
  84511. highLimitValue?: any;
  84512. }
  84513. /**
  84514. * Class used to store any kind of animation
  84515. */
  84516. export class Animation {
  84517. /**Name of the animation */
  84518. name: string;
  84519. /**Property to animate */
  84520. targetProperty: string;
  84521. /**The frames per second of the animation */
  84522. framePerSecond: number;
  84523. /**The data type of the animation */
  84524. dataType: number;
  84525. /**The loop mode of the animation */
  84526. loopMode?: number | undefined;
  84527. /**Specifies if blending should be enabled */
  84528. enableBlending?: boolean | undefined;
  84529. /**
  84530. * Use matrix interpolation instead of using direct key value when animating matrices
  84531. */
  84532. static AllowMatricesInterpolation: boolean;
  84533. /**
  84534. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84535. */
  84536. static AllowMatrixDecomposeForInterpolation: boolean;
  84537. /**
  84538. * Stores the key frames of the animation
  84539. */
  84540. private _keys;
  84541. /**
  84542. * Stores the easing function of the animation
  84543. */
  84544. private _easingFunction;
  84545. /**
  84546. * @hidden Internal use only
  84547. */
  84548. _runtimeAnimations: RuntimeAnimation[];
  84549. /**
  84550. * The set of event that will be linked to this animation
  84551. */
  84552. private _events;
  84553. /**
  84554. * Stores an array of target property paths
  84555. */
  84556. targetPropertyPath: string[];
  84557. /**
  84558. * Stores the blending speed of the animation
  84559. */
  84560. blendingSpeed: number;
  84561. /**
  84562. * Stores the animation ranges for the animation
  84563. */
  84564. private _ranges;
  84565. /**
  84566. * @hidden Internal use
  84567. */
  84568. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84569. /**
  84570. * Sets up an animation
  84571. * @param property The property to animate
  84572. * @param animationType The animation type to apply
  84573. * @param framePerSecond The frames per second of the animation
  84574. * @param easingFunction The easing function used in the animation
  84575. * @returns The created animation
  84576. */
  84577. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84578. /**
  84579. * Create and start an animation on a node
  84580. * @param name defines the name of the global animation that will be run on all nodes
  84581. * @param node defines the root node where the animation will take place
  84582. * @param targetProperty defines property to animate
  84583. * @param framePerSecond defines the number of frame per second yo use
  84584. * @param totalFrame defines the number of frames in total
  84585. * @param from defines the initial value
  84586. * @param to defines the final value
  84587. * @param loopMode defines which loop mode you want to use (off by default)
  84588. * @param easingFunction defines the easing function to use (linear by default)
  84589. * @param onAnimationEnd defines the callback to call when animation end
  84590. * @returns the animatable created for this animation
  84591. */
  84592. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84593. /**
  84594. * Create and start an animation on a node and its descendants
  84595. * @param name defines the name of the global animation that will be run on all nodes
  84596. * @param node defines the root node where the animation will take place
  84597. * @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
  84598. * @param targetProperty defines property to animate
  84599. * @param framePerSecond defines the number of frame per second to use
  84600. * @param totalFrame defines the number of frames in total
  84601. * @param from defines the initial value
  84602. * @param to defines the final value
  84603. * @param loopMode defines which loop mode you want to use (off by default)
  84604. * @param easingFunction defines the easing function to use (linear by default)
  84605. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84606. * @returns the list of animatables created for all nodes
  84607. * @example https://www.babylonjs-playground.com/#MH0VLI
  84608. */
  84609. 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[]>;
  84610. /**
  84611. * Creates a new animation, merges it with the existing animations and starts it
  84612. * @param name Name of the animation
  84613. * @param node Node which contains the scene that begins the animations
  84614. * @param targetProperty Specifies which property to animate
  84615. * @param framePerSecond The frames per second of the animation
  84616. * @param totalFrame The total number of frames
  84617. * @param from The frame at the beginning of the animation
  84618. * @param to The frame at the end of the animation
  84619. * @param loopMode Specifies the loop mode of the animation
  84620. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84621. * @param onAnimationEnd Callback to run once the animation is complete
  84622. * @returns Nullable animation
  84623. */
  84624. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84625. /**
  84626. * Transition property of an host to the target Value
  84627. * @param property The property to transition
  84628. * @param targetValue The target Value of the property
  84629. * @param host The object where the property to animate belongs
  84630. * @param scene Scene used to run the animation
  84631. * @param frameRate Framerate (in frame/s) to use
  84632. * @param transition The transition type we want to use
  84633. * @param duration The duration of the animation, in milliseconds
  84634. * @param onAnimationEnd Callback trigger at the end of the animation
  84635. * @returns Nullable animation
  84636. */
  84637. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84638. /**
  84639. * Return the array of runtime animations currently using this animation
  84640. */
  84641. readonly runtimeAnimations: RuntimeAnimation[];
  84642. /**
  84643. * Specifies if any of the runtime animations are currently running
  84644. */
  84645. readonly hasRunningRuntimeAnimations: boolean;
  84646. /**
  84647. * Initializes the animation
  84648. * @param name Name of the animation
  84649. * @param targetProperty Property to animate
  84650. * @param framePerSecond The frames per second of the animation
  84651. * @param dataType The data type of the animation
  84652. * @param loopMode The loop mode of the animation
  84653. * @param enableBlending Specifies if blending should be enabled
  84654. */
  84655. constructor(
  84656. /**Name of the animation */
  84657. name: string,
  84658. /**Property to animate */
  84659. targetProperty: string,
  84660. /**The frames per second of the animation */
  84661. framePerSecond: number,
  84662. /**The data type of the animation */
  84663. dataType: number,
  84664. /**The loop mode of the animation */
  84665. loopMode?: number | undefined,
  84666. /**Specifies if blending should be enabled */
  84667. enableBlending?: boolean | undefined);
  84668. /**
  84669. * Converts the animation to a string
  84670. * @param fullDetails support for multiple levels of logging within scene loading
  84671. * @returns String form of the animation
  84672. */
  84673. toString(fullDetails?: boolean): string;
  84674. /**
  84675. * Add an event to this animation
  84676. * @param event Event to add
  84677. */
  84678. addEvent(event: AnimationEvent): void;
  84679. /**
  84680. * Remove all events found at the given frame
  84681. * @param frame The frame to remove events from
  84682. */
  84683. removeEvents(frame: number): void;
  84684. /**
  84685. * Retrieves all the events from the animation
  84686. * @returns Events from the animation
  84687. */
  84688. getEvents(): AnimationEvent[];
  84689. /**
  84690. * Creates an animation range
  84691. * @param name Name of the animation range
  84692. * @param from Starting frame of the animation range
  84693. * @param to Ending frame of the animation
  84694. */
  84695. createRange(name: string, from: number, to: number): void;
  84696. /**
  84697. * Deletes an animation range by name
  84698. * @param name Name of the animation range to delete
  84699. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84700. */
  84701. deleteRange(name: string, deleteFrames?: boolean): void;
  84702. /**
  84703. * Gets the animation range by name, or null if not defined
  84704. * @param name Name of the animation range
  84705. * @returns Nullable animation range
  84706. */
  84707. getRange(name: string): Nullable<AnimationRange>;
  84708. /**
  84709. * Gets the key frames from the animation
  84710. * @returns The key frames of the animation
  84711. */
  84712. getKeys(): Array<IAnimationKey>;
  84713. /**
  84714. * Gets the highest frame rate of the animation
  84715. * @returns Highest frame rate of the animation
  84716. */
  84717. getHighestFrame(): number;
  84718. /**
  84719. * Gets the easing function of the animation
  84720. * @returns Easing function of the animation
  84721. */
  84722. getEasingFunction(): IEasingFunction;
  84723. /**
  84724. * Sets the easing function of the animation
  84725. * @param easingFunction A custom mathematical formula for animation
  84726. */
  84727. setEasingFunction(easingFunction: EasingFunction): void;
  84728. /**
  84729. * Interpolates a scalar linearly
  84730. * @param startValue Start value of the animation curve
  84731. * @param endValue End value of the animation curve
  84732. * @param gradient Scalar amount to interpolate
  84733. * @returns Interpolated scalar value
  84734. */
  84735. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  84736. /**
  84737. * Interpolates a scalar cubically
  84738. * @param startValue Start value of the animation curve
  84739. * @param outTangent End tangent of the animation
  84740. * @param endValue End value of the animation curve
  84741. * @param inTangent Start tangent of the animation curve
  84742. * @param gradient Scalar amount to interpolate
  84743. * @returns Interpolated scalar value
  84744. */
  84745. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  84746. /**
  84747. * Interpolates a quaternion using a spherical linear interpolation
  84748. * @param startValue Start value of the animation curve
  84749. * @param endValue End value of the animation curve
  84750. * @param gradient Scalar amount to interpolate
  84751. * @returns Interpolated quaternion value
  84752. */
  84753. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  84754. /**
  84755. * Interpolates a quaternion cubically
  84756. * @param startValue Start value of the animation curve
  84757. * @param outTangent End tangent of the animation curve
  84758. * @param endValue End value of the animation curve
  84759. * @param inTangent Start tangent of the animation curve
  84760. * @param gradient Scalar amount to interpolate
  84761. * @returns Interpolated quaternion value
  84762. */
  84763. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  84764. /**
  84765. * Interpolates a Vector3 linearl
  84766. * @param startValue Start value of the animation curve
  84767. * @param endValue End value of the animation curve
  84768. * @param gradient Scalar amount to interpolate
  84769. * @returns Interpolated scalar value
  84770. */
  84771. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  84772. /**
  84773. * Interpolates a Vector3 cubically
  84774. * @param startValue Start value of the animation curve
  84775. * @param outTangent End tangent of the animation
  84776. * @param endValue End value of the animation curve
  84777. * @param inTangent Start tangent of the animation curve
  84778. * @param gradient Scalar amount to interpolate
  84779. * @returns InterpolatedVector3 value
  84780. */
  84781. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  84782. /**
  84783. * Interpolates a Vector2 linearly
  84784. * @param startValue Start value of the animation curve
  84785. * @param endValue End value of the animation curve
  84786. * @param gradient Scalar amount to interpolate
  84787. * @returns Interpolated Vector2 value
  84788. */
  84789. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  84790. /**
  84791. * Interpolates a Vector2 cubically
  84792. * @param startValue Start value of the animation curve
  84793. * @param outTangent End tangent of the animation
  84794. * @param endValue End value of the animation curve
  84795. * @param inTangent Start tangent of the animation curve
  84796. * @param gradient Scalar amount to interpolate
  84797. * @returns Interpolated Vector2 value
  84798. */
  84799. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  84800. /**
  84801. * Interpolates a size linearly
  84802. * @param startValue Start value of the animation curve
  84803. * @param endValue End value of the animation curve
  84804. * @param gradient Scalar amount to interpolate
  84805. * @returns Interpolated Size value
  84806. */
  84807. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  84808. /**
  84809. * Interpolates a Color3 linearly
  84810. * @param startValue Start value of the animation curve
  84811. * @param endValue End value of the animation curve
  84812. * @param gradient Scalar amount to interpolate
  84813. * @returns Interpolated Color3 value
  84814. */
  84815. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  84816. /**
  84817. * @hidden Internal use only
  84818. */
  84819. _getKeyValue(value: any): any;
  84820. /**
  84821. * @hidden Internal use only
  84822. */
  84823. _interpolate(currentFrame: number, state: _IAnimationState): any;
  84824. /**
  84825. * Defines the function to use to interpolate matrices
  84826. * @param startValue defines the start matrix
  84827. * @param endValue defines the end matrix
  84828. * @param gradient defines the gradient between both matrices
  84829. * @param result defines an optional target matrix where to store the interpolation
  84830. * @returns the interpolated matrix
  84831. */
  84832. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  84833. /**
  84834. * Makes a copy of the animation
  84835. * @returns Cloned animation
  84836. */
  84837. clone(): Animation;
  84838. /**
  84839. * Sets the key frames of the animation
  84840. * @param values The animation key frames to set
  84841. */
  84842. setKeys(values: Array<IAnimationKey>): void;
  84843. /**
  84844. * Serializes the animation to an object
  84845. * @returns Serialized object
  84846. */
  84847. serialize(): any;
  84848. /**
  84849. * Float animation type
  84850. */
  84851. private static _ANIMATIONTYPE_FLOAT;
  84852. /**
  84853. * Vector3 animation type
  84854. */
  84855. private static _ANIMATIONTYPE_VECTOR3;
  84856. /**
  84857. * Quaternion animation type
  84858. */
  84859. private static _ANIMATIONTYPE_QUATERNION;
  84860. /**
  84861. * Matrix animation type
  84862. */
  84863. private static _ANIMATIONTYPE_MATRIX;
  84864. /**
  84865. * Color3 animation type
  84866. */
  84867. private static _ANIMATIONTYPE_COLOR3;
  84868. /**
  84869. * Vector2 animation type
  84870. */
  84871. private static _ANIMATIONTYPE_VECTOR2;
  84872. /**
  84873. * Size animation type
  84874. */
  84875. private static _ANIMATIONTYPE_SIZE;
  84876. /**
  84877. * Relative Loop Mode
  84878. */
  84879. private static _ANIMATIONLOOPMODE_RELATIVE;
  84880. /**
  84881. * Cycle Loop Mode
  84882. */
  84883. private static _ANIMATIONLOOPMODE_CYCLE;
  84884. /**
  84885. * Constant Loop Mode
  84886. */
  84887. private static _ANIMATIONLOOPMODE_CONSTANT;
  84888. /**
  84889. * Get the float animation type
  84890. */
  84891. static readonly ANIMATIONTYPE_FLOAT: number;
  84892. /**
  84893. * Get the Vector3 animation type
  84894. */
  84895. static readonly ANIMATIONTYPE_VECTOR3: number;
  84896. /**
  84897. * Get the Vector2 animation type
  84898. */
  84899. static readonly ANIMATIONTYPE_VECTOR2: number;
  84900. /**
  84901. * Get the Size animation type
  84902. */
  84903. static readonly ANIMATIONTYPE_SIZE: number;
  84904. /**
  84905. * Get the Quaternion animation type
  84906. */
  84907. static readonly ANIMATIONTYPE_QUATERNION: number;
  84908. /**
  84909. * Get the Matrix animation type
  84910. */
  84911. static readonly ANIMATIONTYPE_MATRIX: number;
  84912. /**
  84913. * Get the Color3 animation type
  84914. */
  84915. static readonly ANIMATIONTYPE_COLOR3: number;
  84916. /**
  84917. * Get the Relative Loop Mode
  84918. */
  84919. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  84920. /**
  84921. * Get the Cycle Loop Mode
  84922. */
  84923. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  84924. /**
  84925. * Get the Constant Loop Mode
  84926. */
  84927. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  84928. /** @hidden */
  84929. static _UniversalLerp(left: any, right: any, amount: number): any;
  84930. /**
  84931. * Parses an animation object and creates an animation
  84932. * @param parsedAnimation Parsed animation object
  84933. * @returns Animation object
  84934. */
  84935. static Parse(parsedAnimation: any): Animation;
  84936. /**
  84937. * Appends the serialized animations from the source animations
  84938. * @param source Source containing the animations
  84939. * @param destination Target to store the animations
  84940. */
  84941. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  84942. }
  84943. }
  84944. declare module BABYLON {
  84945. /**
  84946. * Base class of all the textures in babylon.
  84947. * It groups all the common properties the materials, post process, lights... might need
  84948. * in order to make a correct use of the texture.
  84949. */
  84950. export class BaseTexture implements IAnimatable {
  84951. /**
  84952. * Default anisotropic filtering level for the application.
  84953. * It is set to 4 as a good tradeoff between perf and quality.
  84954. */
  84955. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  84956. /**
  84957. * Gets or sets the unique id of the texture
  84958. */
  84959. uniqueId: number;
  84960. /**
  84961. * Define the name of the texture.
  84962. */
  84963. name: string;
  84964. /**
  84965. * Gets or sets an object used to store user defined information.
  84966. */
  84967. metadata: any;
  84968. /**
  84969. * For internal use only. Please do not use.
  84970. */
  84971. reservedDataStore: any;
  84972. private _hasAlpha;
  84973. /**
  84974. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  84975. */
  84976. hasAlpha: boolean;
  84977. /**
  84978. * Defines if the alpha value should be determined via the rgb values.
  84979. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  84980. */
  84981. getAlphaFromRGB: boolean;
  84982. /**
  84983. * Intensity or strength of the texture.
  84984. * It is commonly used by materials to fine tune the intensity of the texture
  84985. */
  84986. level: number;
  84987. /**
  84988. * Define the UV chanel to use starting from 0 and defaulting to 0.
  84989. * This is part of the texture as textures usually maps to one uv set.
  84990. */
  84991. coordinatesIndex: number;
  84992. private _coordinatesMode;
  84993. /**
  84994. * How a texture is mapped.
  84995. *
  84996. * | Value | Type | Description |
  84997. * | ----- | ----------------------------------- | ----------- |
  84998. * | 0 | EXPLICIT_MODE | |
  84999. * | 1 | SPHERICAL_MODE | |
  85000. * | 2 | PLANAR_MODE | |
  85001. * | 3 | CUBIC_MODE | |
  85002. * | 4 | PROJECTION_MODE | |
  85003. * | 5 | SKYBOX_MODE | |
  85004. * | 6 | INVCUBIC_MODE | |
  85005. * | 7 | EQUIRECTANGULAR_MODE | |
  85006. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85007. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85008. */
  85009. coordinatesMode: number;
  85010. /**
  85011. * | Value | Type | Description |
  85012. * | ----- | ------------------ | ----------- |
  85013. * | 0 | CLAMP_ADDRESSMODE | |
  85014. * | 1 | WRAP_ADDRESSMODE | |
  85015. * | 2 | MIRROR_ADDRESSMODE | |
  85016. */
  85017. wrapU: number;
  85018. /**
  85019. * | Value | Type | Description |
  85020. * | ----- | ------------------ | ----------- |
  85021. * | 0 | CLAMP_ADDRESSMODE | |
  85022. * | 1 | WRAP_ADDRESSMODE | |
  85023. * | 2 | MIRROR_ADDRESSMODE | |
  85024. */
  85025. wrapV: number;
  85026. /**
  85027. * | Value | Type | Description |
  85028. * | ----- | ------------------ | ----------- |
  85029. * | 0 | CLAMP_ADDRESSMODE | |
  85030. * | 1 | WRAP_ADDRESSMODE | |
  85031. * | 2 | MIRROR_ADDRESSMODE | |
  85032. */
  85033. wrapR: number;
  85034. /**
  85035. * With compliant hardware and browser (supporting anisotropic filtering)
  85036. * this defines the level of anisotropic filtering in the texture.
  85037. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85038. */
  85039. anisotropicFilteringLevel: number;
  85040. /**
  85041. * Define if the texture is a cube texture or if false a 2d texture.
  85042. */
  85043. isCube: boolean;
  85044. /**
  85045. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85046. */
  85047. is3D: boolean;
  85048. /**
  85049. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85050. * HDR texture are usually stored in linear space.
  85051. * This only impacts the PBR and Background materials
  85052. */
  85053. gammaSpace: boolean;
  85054. /**
  85055. * Gets whether or not the texture contains RGBD data.
  85056. */
  85057. readonly isRGBD: boolean;
  85058. /**
  85059. * Is Z inverted in the texture (useful in a cube texture).
  85060. */
  85061. invertZ: boolean;
  85062. /**
  85063. * Are mip maps generated for this texture or not.
  85064. */
  85065. readonly noMipmap: boolean;
  85066. /**
  85067. * @hidden
  85068. */
  85069. lodLevelInAlpha: boolean;
  85070. /**
  85071. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85072. */
  85073. lodGenerationOffset: number;
  85074. /**
  85075. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85076. */
  85077. lodGenerationScale: number;
  85078. /**
  85079. * Define if the texture is a render target.
  85080. */
  85081. isRenderTarget: boolean;
  85082. /**
  85083. * Define the unique id of the texture in the scene.
  85084. */
  85085. readonly uid: string;
  85086. /**
  85087. * Return a string representation of the texture.
  85088. * @returns the texture as a string
  85089. */
  85090. toString(): string;
  85091. /**
  85092. * Get the class name of the texture.
  85093. * @returns "BaseTexture"
  85094. */
  85095. getClassName(): string;
  85096. /**
  85097. * Define the list of animation attached to the texture.
  85098. */
  85099. animations: Animation[];
  85100. /**
  85101. * An event triggered when the texture is disposed.
  85102. */
  85103. onDisposeObservable: Observable<BaseTexture>;
  85104. private _onDisposeObserver;
  85105. /**
  85106. * Callback triggered when the texture has been disposed.
  85107. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85108. */
  85109. onDispose: () => void;
  85110. /**
  85111. * Define the current state of the loading sequence when in delayed load mode.
  85112. */
  85113. delayLoadState: number;
  85114. private _scene;
  85115. /** @hidden */
  85116. _texture: Nullable<InternalTexture>;
  85117. private _uid;
  85118. /**
  85119. * Define if the texture is preventinga material to render or not.
  85120. * If not and the texture is not ready, the engine will use a default black texture instead.
  85121. */
  85122. readonly isBlocking: boolean;
  85123. /**
  85124. * Instantiates a new BaseTexture.
  85125. * Base class of all the textures in babylon.
  85126. * It groups all the common properties the materials, post process, lights... might need
  85127. * in order to make a correct use of the texture.
  85128. * @param scene Define the scene the texture blongs to
  85129. */
  85130. constructor(scene: Nullable<Scene>);
  85131. /**
  85132. * Get the scene the texture belongs to.
  85133. * @returns the scene or null if undefined
  85134. */
  85135. getScene(): Nullable<Scene>;
  85136. /**
  85137. * Get the texture transform matrix used to offset tile the texture for istance.
  85138. * @returns the transformation matrix
  85139. */
  85140. getTextureMatrix(): Matrix;
  85141. /**
  85142. * Get the texture reflection matrix used to rotate/transform the reflection.
  85143. * @returns the reflection matrix
  85144. */
  85145. getReflectionTextureMatrix(): Matrix;
  85146. /**
  85147. * Get the underlying lower level texture from Babylon.
  85148. * @returns the insternal texture
  85149. */
  85150. getInternalTexture(): Nullable<InternalTexture>;
  85151. /**
  85152. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85153. * @returns true if ready or not blocking
  85154. */
  85155. isReadyOrNotBlocking(): boolean;
  85156. /**
  85157. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85158. * @returns true if fully ready
  85159. */
  85160. isReady(): boolean;
  85161. private _cachedSize;
  85162. /**
  85163. * Get the size of the texture.
  85164. * @returns the texture size.
  85165. */
  85166. getSize(): ISize;
  85167. /**
  85168. * Get the base size of the texture.
  85169. * It can be different from the size if the texture has been resized for POT for instance
  85170. * @returns the base size
  85171. */
  85172. getBaseSize(): ISize;
  85173. /**
  85174. * Update the sampling mode of the texture.
  85175. * Default is Trilinear mode.
  85176. *
  85177. * | Value | Type | Description |
  85178. * | ----- | ------------------ | ----------- |
  85179. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85180. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85181. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85182. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85183. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85184. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85185. * | 7 | NEAREST_LINEAR | |
  85186. * | 8 | NEAREST_NEAREST | |
  85187. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85188. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85189. * | 11 | LINEAR_LINEAR | |
  85190. * | 12 | LINEAR_NEAREST | |
  85191. *
  85192. * > _mag_: magnification filter (close to the viewer)
  85193. * > _min_: minification filter (far from the viewer)
  85194. * > _mip_: filter used between mip map levels
  85195. *@param samplingMode Define the new sampling mode of the texture
  85196. */
  85197. updateSamplingMode(samplingMode: number): void;
  85198. /**
  85199. * Scales the texture if is `canRescale()`
  85200. * @param ratio the resize factor we want to use to rescale
  85201. */
  85202. scale(ratio: number): void;
  85203. /**
  85204. * Get if the texture can rescale.
  85205. */
  85206. readonly canRescale: boolean;
  85207. /** @hidden */
  85208. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85209. /** @hidden */
  85210. _rebuild(): void;
  85211. /**
  85212. * Triggers the load sequence in delayed load mode.
  85213. */
  85214. delayLoad(): void;
  85215. /**
  85216. * Clones the texture.
  85217. * @returns the cloned texture
  85218. */
  85219. clone(): Nullable<BaseTexture>;
  85220. /**
  85221. * Get the texture underlying type (INT, FLOAT...)
  85222. */
  85223. readonly textureType: number;
  85224. /**
  85225. * Get the texture underlying format (RGB, RGBA...)
  85226. */
  85227. readonly textureFormat: number;
  85228. /**
  85229. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85230. * This will returns an RGBA array buffer containing either in values (0-255) or
  85231. * float values (0-1) depending of the underlying buffer type.
  85232. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85233. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85234. * @param buffer defines a user defined buffer to fill with data (can be null)
  85235. * @returns The Array buffer containing the pixels data.
  85236. */
  85237. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85238. /**
  85239. * Release and destroy the underlying lower level texture aka internalTexture.
  85240. */
  85241. releaseInternalTexture(): void;
  85242. /**
  85243. * Get the polynomial representation of the texture data.
  85244. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85245. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85246. */
  85247. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85248. /** @hidden */
  85249. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85250. /** @hidden */
  85251. readonly _lodTextureMid: Nullable<BaseTexture>;
  85252. /** @hidden */
  85253. readonly _lodTextureLow: Nullable<BaseTexture>;
  85254. /**
  85255. * Dispose the texture and release its associated resources.
  85256. */
  85257. dispose(): void;
  85258. /**
  85259. * Serialize the texture into a JSON representation that can be parsed later on.
  85260. * @returns the JSON representation of the texture
  85261. */
  85262. serialize(): any;
  85263. /**
  85264. * Helper function to be called back once a list of texture contains only ready textures.
  85265. * @param textures Define the list of textures to wait for
  85266. * @param callback Define the callback triggered once the entire list will be ready
  85267. */
  85268. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85269. }
  85270. }
  85271. declare module BABYLON {
  85272. /**
  85273. * Uniform buffer objects.
  85274. *
  85275. * Handles blocks of uniform on the GPU.
  85276. *
  85277. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85278. *
  85279. * For more information, please refer to :
  85280. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85281. */
  85282. export class UniformBuffer {
  85283. private _engine;
  85284. private _buffer;
  85285. private _data;
  85286. private _bufferData;
  85287. private _dynamic?;
  85288. private _uniformLocations;
  85289. private _uniformSizes;
  85290. private _uniformLocationPointer;
  85291. private _needSync;
  85292. private _noUBO;
  85293. private _currentEffect;
  85294. private static _MAX_UNIFORM_SIZE;
  85295. private static _tempBuffer;
  85296. /**
  85297. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85298. * This is dynamic to allow compat with webgl 1 and 2.
  85299. * You will need to pass the name of the uniform as well as the value.
  85300. */
  85301. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85302. /**
  85303. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85304. * This is dynamic to allow compat with webgl 1 and 2.
  85305. * You will need to pass the name of the uniform as well as the value.
  85306. */
  85307. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85308. /**
  85309. * Lambda to Update a single float in a uniform buffer.
  85310. * This is dynamic to allow compat with webgl 1 and 2.
  85311. * You will need to pass the name of the uniform as well as the value.
  85312. */
  85313. updateFloat: (name: string, x: number) => void;
  85314. /**
  85315. * Lambda to Update a vec2 of float in a uniform buffer.
  85316. * This is dynamic to allow compat with webgl 1 and 2.
  85317. * You will need to pass the name of the uniform as well as the value.
  85318. */
  85319. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85320. /**
  85321. * Lambda to Update a vec3 of float in a uniform buffer.
  85322. * This is dynamic to allow compat with webgl 1 and 2.
  85323. * You will need to pass the name of the uniform as well as the value.
  85324. */
  85325. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85326. /**
  85327. * Lambda to Update a vec4 of float in a uniform buffer.
  85328. * This is dynamic to allow compat with webgl 1 and 2.
  85329. * You will need to pass the name of the uniform as well as the value.
  85330. */
  85331. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85332. /**
  85333. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85334. * This is dynamic to allow compat with webgl 1 and 2.
  85335. * You will need to pass the name of the uniform as well as the value.
  85336. */
  85337. updateMatrix: (name: string, mat: Matrix) => void;
  85338. /**
  85339. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85340. * This is dynamic to allow compat with webgl 1 and 2.
  85341. * You will need to pass the name of the uniform as well as the value.
  85342. */
  85343. updateVector3: (name: string, vector: Vector3) => void;
  85344. /**
  85345. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85346. * This is dynamic to allow compat with webgl 1 and 2.
  85347. * You will need to pass the name of the uniform as well as the value.
  85348. */
  85349. updateVector4: (name: string, vector: Vector4) => void;
  85350. /**
  85351. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85352. * This is dynamic to allow compat with webgl 1 and 2.
  85353. * You will need to pass the name of the uniform as well as the value.
  85354. */
  85355. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85356. /**
  85357. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85358. * This is dynamic to allow compat with webgl 1 and 2.
  85359. * You will need to pass the name of the uniform as well as the value.
  85360. */
  85361. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85362. /**
  85363. * Instantiates a new Uniform buffer objects.
  85364. *
  85365. * Handles blocks of uniform on the GPU.
  85366. *
  85367. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85368. *
  85369. * For more information, please refer to :
  85370. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85371. * @param engine Define the engine the buffer is associated with
  85372. * @param data Define the data contained in the buffer
  85373. * @param dynamic Define if the buffer is updatable
  85374. */
  85375. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85376. /**
  85377. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85378. * or just falling back on setUniformXXX calls.
  85379. */
  85380. readonly useUbo: boolean;
  85381. /**
  85382. * Indicates if the WebGL underlying uniform buffer is in sync
  85383. * with the javascript cache data.
  85384. */
  85385. readonly isSync: boolean;
  85386. /**
  85387. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85388. * Also, a dynamic UniformBuffer will disable cache verification and always
  85389. * update the underlying WebGL uniform buffer to the GPU.
  85390. * @returns if Dynamic, otherwise false
  85391. */
  85392. isDynamic(): boolean;
  85393. /**
  85394. * The data cache on JS side.
  85395. * @returns the underlying data as a float array
  85396. */
  85397. getData(): Float32Array;
  85398. /**
  85399. * The underlying WebGL Uniform buffer.
  85400. * @returns the webgl buffer
  85401. */
  85402. getBuffer(): Nullable<WebGLBuffer>;
  85403. /**
  85404. * std140 layout specifies how to align data within an UBO structure.
  85405. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85406. * for specs.
  85407. */
  85408. private _fillAlignment;
  85409. /**
  85410. * Adds an uniform in the buffer.
  85411. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85412. * for the layout to be correct !
  85413. * @param name Name of the uniform, as used in the uniform block in the shader.
  85414. * @param size Data size, or data directly.
  85415. */
  85416. addUniform(name: string, size: number | number[]): void;
  85417. /**
  85418. * Adds a Matrix 4x4 to the uniform buffer.
  85419. * @param name Name of the uniform, as used in the uniform block in the shader.
  85420. * @param mat A 4x4 matrix.
  85421. */
  85422. addMatrix(name: string, mat: Matrix): void;
  85423. /**
  85424. * Adds a vec2 to the uniform buffer.
  85425. * @param name Name of the uniform, as used in the uniform block in the shader.
  85426. * @param x Define the x component value of the vec2
  85427. * @param y Define the y component value of the vec2
  85428. */
  85429. addFloat2(name: string, x: number, y: number): void;
  85430. /**
  85431. * Adds a vec3 to the uniform buffer.
  85432. * @param name Name of the uniform, as used in the uniform block in the shader.
  85433. * @param x Define the x component value of the vec3
  85434. * @param y Define the y component value of the vec3
  85435. * @param z Define the z component value of the vec3
  85436. */
  85437. addFloat3(name: string, x: number, y: number, z: number): void;
  85438. /**
  85439. * Adds a vec3 to the uniform buffer.
  85440. * @param name Name of the uniform, as used in the uniform block in the shader.
  85441. * @param color Define the vec3 from a Color
  85442. */
  85443. addColor3(name: string, color: Color3): void;
  85444. /**
  85445. * Adds a vec4 to the uniform buffer.
  85446. * @param name Name of the uniform, as used in the uniform block in the shader.
  85447. * @param color Define the rgb components from a Color
  85448. * @param alpha Define the a component of the vec4
  85449. */
  85450. addColor4(name: string, color: Color3, alpha: number): void;
  85451. /**
  85452. * Adds a vec3 to the uniform buffer.
  85453. * @param name Name of the uniform, as used in the uniform block in the shader.
  85454. * @param vector Define the vec3 components from a Vector
  85455. */
  85456. addVector3(name: string, vector: Vector3): void;
  85457. /**
  85458. * Adds a Matrix 3x3 to the uniform buffer.
  85459. * @param name Name of the uniform, as used in the uniform block in the shader.
  85460. */
  85461. addMatrix3x3(name: string): void;
  85462. /**
  85463. * Adds a Matrix 2x2 to the uniform buffer.
  85464. * @param name Name of the uniform, as used in the uniform block in the shader.
  85465. */
  85466. addMatrix2x2(name: string): void;
  85467. /**
  85468. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85469. */
  85470. create(): void;
  85471. /** @hidden */
  85472. _rebuild(): void;
  85473. /**
  85474. * Updates the WebGL Uniform Buffer on the GPU.
  85475. * If the `dynamic` flag is set to true, no cache comparison is done.
  85476. * Otherwise, the buffer will be updated only if the cache differs.
  85477. */
  85478. update(): void;
  85479. /**
  85480. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85481. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85482. * @param data Define the flattened data
  85483. * @param size Define the size of the data.
  85484. */
  85485. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85486. private _updateMatrix3x3ForUniform;
  85487. private _updateMatrix3x3ForEffect;
  85488. private _updateMatrix2x2ForEffect;
  85489. private _updateMatrix2x2ForUniform;
  85490. private _updateFloatForEffect;
  85491. private _updateFloatForUniform;
  85492. private _updateFloat2ForEffect;
  85493. private _updateFloat2ForUniform;
  85494. private _updateFloat3ForEffect;
  85495. private _updateFloat3ForUniform;
  85496. private _updateFloat4ForEffect;
  85497. private _updateFloat4ForUniform;
  85498. private _updateMatrixForEffect;
  85499. private _updateMatrixForUniform;
  85500. private _updateVector3ForEffect;
  85501. private _updateVector3ForUniform;
  85502. private _updateVector4ForEffect;
  85503. private _updateVector4ForUniform;
  85504. private _updateColor3ForEffect;
  85505. private _updateColor3ForUniform;
  85506. private _updateColor4ForEffect;
  85507. private _updateColor4ForUniform;
  85508. /**
  85509. * Sets a sampler uniform on the effect.
  85510. * @param name Define the name of the sampler.
  85511. * @param texture Define the texture to set in the sampler
  85512. */
  85513. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85514. /**
  85515. * Directly updates the value of the uniform in the cache AND on the GPU.
  85516. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85517. * @param data Define the flattened data
  85518. */
  85519. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85520. /**
  85521. * Binds this uniform buffer to an effect.
  85522. * @param effect Define the effect to bind the buffer to
  85523. * @param name Name of the uniform block in the shader.
  85524. */
  85525. bindToEffect(effect: Effect, name: string): void;
  85526. /**
  85527. * Disposes the uniform buffer.
  85528. */
  85529. dispose(): void;
  85530. }
  85531. }
  85532. declare module BABYLON {
  85533. /**
  85534. * This represents the required contract to create a new type of texture loader.
  85535. */
  85536. export interface IInternalTextureLoader {
  85537. /**
  85538. * Defines wether the loader supports cascade loading the different faces.
  85539. */
  85540. supportCascades: boolean;
  85541. /**
  85542. * This returns if the loader support the current file information.
  85543. * @param extension defines the file extension of the file being loaded
  85544. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85545. * @param fallback defines the fallback internal texture if any
  85546. * @param isBase64 defines whether the texture is encoded as a base64
  85547. * @param isBuffer defines whether the texture data are stored as a buffer
  85548. * @returns true if the loader can load the specified file
  85549. */
  85550. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85551. /**
  85552. * Transform the url before loading if required.
  85553. * @param rootUrl the url of the texture
  85554. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85555. * @returns the transformed texture
  85556. */
  85557. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85558. /**
  85559. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85560. * @param rootUrl the url of the texture
  85561. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85562. * @returns the fallback texture
  85563. */
  85564. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85565. /**
  85566. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85567. * @param data contains the texture data
  85568. * @param texture defines the BabylonJS internal texture
  85569. * @param createPolynomials will be true if polynomials have been requested
  85570. * @param onLoad defines the callback to trigger once the texture is ready
  85571. * @param onError defines the callback to trigger in case of error
  85572. */
  85573. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85574. /**
  85575. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85576. * @param data contains the texture data
  85577. * @param texture defines the BabylonJS internal texture
  85578. * @param callback defines the method to call once ready to upload
  85579. */
  85580. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85581. }
  85582. }
  85583. declare module BABYLON {
  85584. /**
  85585. * Creation options of the multi render target texture.
  85586. */
  85587. export interface IMultiRenderTargetOptions {
  85588. /**
  85589. * Define if the texture needs to create mip maps after render.
  85590. */
  85591. generateMipMaps?: boolean;
  85592. /**
  85593. * Define the types of all the draw buffers we want to create
  85594. */
  85595. types?: number[];
  85596. /**
  85597. * Define the sampling modes of all the draw buffers we want to create
  85598. */
  85599. samplingModes?: number[];
  85600. /**
  85601. * Define if a depth buffer is required
  85602. */
  85603. generateDepthBuffer?: boolean;
  85604. /**
  85605. * Define if a stencil buffer is required
  85606. */
  85607. generateStencilBuffer?: boolean;
  85608. /**
  85609. * Define if a depth texture is required instead of a depth buffer
  85610. */
  85611. generateDepthTexture?: boolean;
  85612. /**
  85613. * Define the number of desired draw buffers
  85614. */
  85615. textureCount?: number;
  85616. /**
  85617. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85618. */
  85619. doNotChangeAspectRatio?: boolean;
  85620. /**
  85621. * Define the default type of the buffers we are creating
  85622. */
  85623. defaultType?: number;
  85624. }
  85625. /**
  85626. * A multi render target, like a render target provides the ability to render to a texture.
  85627. * Unlike the render target, it can render to several draw buffers in one draw.
  85628. * This is specially interesting in deferred rendering or for any effects requiring more than
  85629. * just one color from a single pass.
  85630. */
  85631. export class MultiRenderTarget extends RenderTargetTexture {
  85632. private _internalTextures;
  85633. private _textures;
  85634. private _multiRenderTargetOptions;
  85635. /**
  85636. * Get if draw buffers are currently supported by the used hardware and browser.
  85637. */
  85638. readonly isSupported: boolean;
  85639. /**
  85640. * Get the list of textures generated by the multi render target.
  85641. */
  85642. readonly textures: Texture[];
  85643. /**
  85644. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85645. */
  85646. readonly depthTexture: Texture;
  85647. /**
  85648. * Set the wrapping mode on U of all the textures we are rendering to.
  85649. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85650. */
  85651. wrapU: number;
  85652. /**
  85653. * Set the wrapping mode on V of all the textures we are rendering to.
  85654. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85655. */
  85656. wrapV: number;
  85657. /**
  85658. * Instantiate a new multi render target texture.
  85659. * A multi render target, like a render target provides the ability to render to a texture.
  85660. * Unlike the render target, it can render to several draw buffers in one draw.
  85661. * This is specially interesting in deferred rendering or for any effects requiring more than
  85662. * just one color from a single pass.
  85663. * @param name Define the name of the texture
  85664. * @param size Define the size of the buffers to render to
  85665. * @param count Define the number of target we are rendering into
  85666. * @param scene Define the scene the texture belongs to
  85667. * @param options Define the options used to create the multi render target
  85668. */
  85669. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85670. /** @hidden */
  85671. _rebuild(): void;
  85672. private _createInternalTextures;
  85673. private _createTextures;
  85674. /**
  85675. * Define the number of samples used if MSAA is enabled.
  85676. */
  85677. samples: number;
  85678. /**
  85679. * Resize all the textures in the multi render target.
  85680. * Be carrefull as it will recreate all the data in the new texture.
  85681. * @param size Define the new size
  85682. */
  85683. resize(size: any): void;
  85684. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85685. /**
  85686. * Dispose the render targets and their associated resources
  85687. */
  85688. dispose(): void;
  85689. /**
  85690. * Release all the underlying texture used as draw buffers.
  85691. */
  85692. releaseInternalTextures(): void;
  85693. }
  85694. }
  85695. declare module BABYLON {
  85696. /**
  85697. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85698. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85699. */
  85700. export class Analyser {
  85701. /**
  85702. * Gets or sets the smoothing
  85703. * @ignorenaming
  85704. */
  85705. SMOOTHING: number;
  85706. /**
  85707. * Gets or sets the FFT table size
  85708. * @ignorenaming
  85709. */
  85710. FFT_SIZE: number;
  85711. /**
  85712. * Gets or sets the bar graph amplitude
  85713. * @ignorenaming
  85714. */
  85715. BARGRAPHAMPLITUDE: number;
  85716. /**
  85717. * Gets or sets the position of the debug canvas
  85718. * @ignorenaming
  85719. */
  85720. DEBUGCANVASPOS: {
  85721. x: number;
  85722. y: number;
  85723. };
  85724. /**
  85725. * Gets or sets the debug canvas size
  85726. * @ignorenaming
  85727. */
  85728. DEBUGCANVASSIZE: {
  85729. width: number;
  85730. height: number;
  85731. };
  85732. private _byteFreqs;
  85733. private _byteTime;
  85734. private _floatFreqs;
  85735. private _webAudioAnalyser;
  85736. private _debugCanvas;
  85737. private _debugCanvasContext;
  85738. private _scene;
  85739. private _registerFunc;
  85740. private _audioEngine;
  85741. /**
  85742. * Creates a new analyser
  85743. * @param scene defines hosting scene
  85744. */
  85745. constructor(scene: Scene);
  85746. /**
  85747. * Get the number of data values you will have to play with for the visualization
  85748. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  85749. * @returns a number
  85750. */
  85751. getFrequencyBinCount(): number;
  85752. /**
  85753. * Gets the current frequency data as a byte array
  85754. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85755. * @returns a Uint8Array
  85756. */
  85757. getByteFrequencyData(): Uint8Array;
  85758. /**
  85759. * Gets the current waveform as a byte array
  85760. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  85761. * @returns a Uint8Array
  85762. */
  85763. getByteTimeDomainData(): Uint8Array;
  85764. /**
  85765. * Gets the current frequency data as a float array
  85766. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  85767. * @returns a Float32Array
  85768. */
  85769. getFloatFrequencyData(): Float32Array;
  85770. /**
  85771. * Renders the debug canvas
  85772. */
  85773. drawDebugCanvas(): void;
  85774. /**
  85775. * Stops rendering the debug canvas and removes it
  85776. */
  85777. stopDebugCanvas(): void;
  85778. /**
  85779. * Connects two audio nodes
  85780. * @param inputAudioNode defines first node to connect
  85781. * @param outputAudioNode defines second node to connect
  85782. */
  85783. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  85784. /**
  85785. * Releases all associated resources
  85786. */
  85787. dispose(): void;
  85788. }
  85789. }
  85790. declare module BABYLON {
  85791. /**
  85792. * This represents an audio engine and it is responsible
  85793. * to play, synchronize and analyse sounds throughout the application.
  85794. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85795. */
  85796. export interface IAudioEngine extends IDisposable {
  85797. /**
  85798. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85799. */
  85800. readonly canUseWebAudio: boolean;
  85801. /**
  85802. * Gets the current AudioContext if available.
  85803. */
  85804. readonly audioContext: Nullable<AudioContext>;
  85805. /**
  85806. * The master gain node defines the global audio volume of your audio engine.
  85807. */
  85808. readonly masterGain: GainNode;
  85809. /**
  85810. * Gets whether or not mp3 are supported by your browser.
  85811. */
  85812. readonly isMP3supported: boolean;
  85813. /**
  85814. * Gets whether or not ogg are supported by your browser.
  85815. */
  85816. readonly isOGGsupported: boolean;
  85817. /**
  85818. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85819. * @ignoreNaming
  85820. */
  85821. WarnedWebAudioUnsupported: boolean;
  85822. /**
  85823. * Defines if the audio engine relies on a custom unlocked button.
  85824. * In this case, the embedded button will not be displayed.
  85825. */
  85826. useCustomUnlockedButton: boolean;
  85827. /**
  85828. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  85829. */
  85830. readonly unlocked: boolean;
  85831. /**
  85832. * Event raised when audio has been unlocked on the browser.
  85833. */
  85834. onAudioUnlockedObservable: Observable<AudioEngine>;
  85835. /**
  85836. * Event raised when audio has been locked on the browser.
  85837. */
  85838. onAudioLockedObservable: Observable<AudioEngine>;
  85839. /**
  85840. * Flags the audio engine in Locked state.
  85841. * This happens due to new browser policies preventing audio to autoplay.
  85842. */
  85843. lock(): void;
  85844. /**
  85845. * Unlocks the audio engine once a user action has been done on the dom.
  85846. * This is helpful to resume play once browser policies have been satisfied.
  85847. */
  85848. unlock(): void;
  85849. }
  85850. /**
  85851. * This represents the default audio engine used in babylon.
  85852. * It is responsible to play, synchronize and analyse sounds throughout the application.
  85853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85854. */
  85855. export class AudioEngine implements IAudioEngine {
  85856. private _audioContext;
  85857. private _audioContextInitialized;
  85858. private _muteButton;
  85859. private _hostElement;
  85860. /**
  85861. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  85862. */
  85863. canUseWebAudio: boolean;
  85864. /**
  85865. * The master gain node defines the global audio volume of your audio engine.
  85866. */
  85867. masterGain: GainNode;
  85868. /**
  85869. * Defines if Babylon should emit a warning if WebAudio is not supported.
  85870. * @ignoreNaming
  85871. */
  85872. WarnedWebAudioUnsupported: boolean;
  85873. /**
  85874. * Gets whether or not mp3 are supported by your browser.
  85875. */
  85876. isMP3supported: boolean;
  85877. /**
  85878. * Gets whether or not ogg are supported by your browser.
  85879. */
  85880. isOGGsupported: boolean;
  85881. /**
  85882. * Gets whether audio has been unlocked on the device.
  85883. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  85884. * a user interaction has happened.
  85885. */
  85886. unlocked: boolean;
  85887. /**
  85888. * Defines if the audio engine relies on a custom unlocked button.
  85889. * In this case, the embedded button will not be displayed.
  85890. */
  85891. useCustomUnlockedButton: boolean;
  85892. /**
  85893. * Event raised when audio has been unlocked on the browser.
  85894. */
  85895. onAudioUnlockedObservable: Observable<AudioEngine>;
  85896. /**
  85897. * Event raised when audio has been locked on the browser.
  85898. */
  85899. onAudioLockedObservable: Observable<AudioEngine>;
  85900. /**
  85901. * Gets the current AudioContext if available.
  85902. */
  85903. readonly audioContext: Nullable<AudioContext>;
  85904. private _connectedAnalyser;
  85905. /**
  85906. * Instantiates a new audio engine.
  85907. *
  85908. * There should be only one per page as some browsers restrict the number
  85909. * of audio contexts you can create.
  85910. * @param hostElement defines the host element where to display the mute icon if necessary
  85911. */
  85912. constructor(hostElement?: Nullable<HTMLElement>);
  85913. /**
  85914. * Flags the audio engine in Locked state.
  85915. * This happens due to new browser policies preventing audio to autoplay.
  85916. */
  85917. lock(): void;
  85918. /**
  85919. * Unlocks the audio engine once a user action has been done on the dom.
  85920. * This is helpful to resume play once browser policies have been satisfied.
  85921. */
  85922. unlock(): void;
  85923. private _resumeAudioContext;
  85924. private _initializeAudioContext;
  85925. private _tryToRun;
  85926. private _triggerRunningState;
  85927. private _triggerSuspendedState;
  85928. private _displayMuteButton;
  85929. private _moveButtonToTopLeft;
  85930. private _onResize;
  85931. private _hideMuteButton;
  85932. /**
  85933. * Destroy and release the resources associated with the audio ccontext.
  85934. */
  85935. dispose(): void;
  85936. /**
  85937. * Gets the global volume sets on the master gain.
  85938. * @returns the global volume if set or -1 otherwise
  85939. */
  85940. getGlobalVolume(): number;
  85941. /**
  85942. * Sets the global volume of your experience (sets on the master gain).
  85943. * @param newVolume Defines the new global volume of the application
  85944. */
  85945. setGlobalVolume(newVolume: number): void;
  85946. /**
  85947. * Connect the audio engine to an audio analyser allowing some amazing
  85948. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  85949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  85950. * @param analyser The analyser to connect to the engine
  85951. */
  85952. connectToAnalyser(analyser: Analyser): void;
  85953. }
  85954. }
  85955. declare module BABYLON {
  85956. /**
  85957. * Interface used to present a loading screen while loading a scene
  85958. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85959. */
  85960. export interface ILoadingScreen {
  85961. /**
  85962. * Function called to display the loading screen
  85963. */
  85964. displayLoadingUI: () => void;
  85965. /**
  85966. * Function called to hide the loading screen
  85967. */
  85968. hideLoadingUI: () => void;
  85969. /**
  85970. * Gets or sets the color to use for the background
  85971. */
  85972. loadingUIBackgroundColor: string;
  85973. /**
  85974. * Gets or sets the text to display while loading
  85975. */
  85976. loadingUIText: string;
  85977. }
  85978. /**
  85979. * Class used for the default loading screen
  85980. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  85981. */
  85982. export class DefaultLoadingScreen implements ILoadingScreen {
  85983. private _renderingCanvas;
  85984. private _loadingText;
  85985. private _loadingDivBackgroundColor;
  85986. private _loadingDiv;
  85987. private _loadingTextDiv;
  85988. /**
  85989. * Creates a new default loading screen
  85990. * @param _renderingCanvas defines the canvas used to render the scene
  85991. * @param _loadingText defines the default text to display
  85992. * @param _loadingDivBackgroundColor defines the default background color
  85993. */
  85994. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  85995. /**
  85996. * Function called to display the loading screen
  85997. */
  85998. displayLoadingUI(): void;
  85999. /**
  86000. * Function called to hide the loading screen
  86001. */
  86002. hideLoadingUI(): void;
  86003. /**
  86004. * Gets or sets the text to display while loading
  86005. */
  86006. loadingUIText: string;
  86007. /**
  86008. * Gets or sets the color to use for the background
  86009. */
  86010. loadingUIBackgroundColor: string;
  86011. private _resizeLoadingUI;
  86012. }
  86013. }
  86014. declare module BABYLON {
  86015. /**
  86016. * Settings for finer control over video usage
  86017. */
  86018. export interface VideoTextureSettings {
  86019. /**
  86020. * Applies `autoplay` to video, if specified
  86021. */
  86022. autoPlay?: boolean;
  86023. /**
  86024. * Applies `loop` to video, if specified
  86025. */
  86026. loop?: boolean;
  86027. /**
  86028. * Automatically updates internal texture from video at every frame in the render loop
  86029. */
  86030. autoUpdateTexture: boolean;
  86031. /**
  86032. * Image src displayed during the video loading or until the user interacts with the video.
  86033. */
  86034. poster?: string;
  86035. }
  86036. /**
  86037. * If you want to display a video in your scene, this is the special texture for that.
  86038. * This special texture works similar to other textures, with the exception of a few parameters.
  86039. * @see https://doc.babylonjs.com/how_to/video_texture
  86040. */
  86041. export class VideoTexture extends Texture {
  86042. /**
  86043. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86044. */
  86045. readonly autoUpdateTexture: boolean;
  86046. /**
  86047. * The video instance used by the texture internally
  86048. */
  86049. readonly video: HTMLVideoElement;
  86050. private _onUserActionRequestedObservable;
  86051. /**
  86052. * Event triggerd when a dom action is required by the user to play the video.
  86053. * This happens due to recent changes in browser policies preventing video to auto start.
  86054. */
  86055. readonly onUserActionRequestedObservable: Observable<Texture>;
  86056. private _generateMipMaps;
  86057. private _engine;
  86058. private _stillImageCaptured;
  86059. private _displayingPosterTexture;
  86060. private _settings;
  86061. private _createInternalTextureOnEvent;
  86062. /**
  86063. * Creates a video texture.
  86064. * If you want to display a video in your scene, this is the special texture for that.
  86065. * This special texture works similar to other textures, with the exception of a few parameters.
  86066. * @see https://doc.babylonjs.com/how_to/video_texture
  86067. * @param name optional name, will detect from video source, if not defined
  86068. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86069. * @param scene is obviously the current scene.
  86070. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86071. * @param invertY is false by default but can be used to invert video on Y axis
  86072. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86073. * @param settings allows finer control over video usage
  86074. */
  86075. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86076. private _getName;
  86077. private _getVideo;
  86078. private _createInternalTexture;
  86079. private reset;
  86080. /**
  86081. * @hidden Internal method to initiate `update`.
  86082. */
  86083. _rebuild(): void;
  86084. /**
  86085. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86086. */
  86087. update(): void;
  86088. /**
  86089. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86090. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86091. */
  86092. updateTexture(isVisible: boolean): void;
  86093. protected _updateInternalTexture: () => void;
  86094. /**
  86095. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86096. * @param url New url.
  86097. */
  86098. updateURL(url: string): void;
  86099. /**
  86100. * Dispose the texture and release its associated resources.
  86101. */
  86102. dispose(): void;
  86103. /**
  86104. * Creates a video texture straight from a stream.
  86105. * @param scene Define the scene the texture should be created in
  86106. * @param stream Define the stream the texture should be created from
  86107. * @returns The created video texture as a promise
  86108. */
  86109. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86110. /**
  86111. * Creates a video texture straight from your WebCam video feed.
  86112. * @param scene Define the scene the texture should be created in
  86113. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86114. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86115. * @returns The created video texture as a promise
  86116. */
  86117. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86118. minWidth: number;
  86119. maxWidth: number;
  86120. minHeight: number;
  86121. maxHeight: number;
  86122. deviceId: string;
  86123. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86124. /**
  86125. * Creates a video texture straight from your WebCam video feed.
  86126. * @param scene Define the scene the texture should be created in
  86127. * @param onReady Define a callback to triggered once the texture will be ready
  86128. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86129. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86130. */
  86131. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86132. minWidth: number;
  86133. maxWidth: number;
  86134. minHeight: number;
  86135. maxHeight: number;
  86136. deviceId: string;
  86137. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86138. }
  86139. }
  86140. declare module BABYLON {
  86141. /**
  86142. * Interface for attribute information associated with buffer instanciation
  86143. */
  86144. export class InstancingAttributeInfo {
  86145. /**
  86146. * Index/offset of the attribute in the vertex shader
  86147. */
  86148. index: number;
  86149. /**
  86150. * size of the attribute, 1, 2, 3 or 4
  86151. */
  86152. attributeSize: number;
  86153. /**
  86154. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86155. * default is FLOAT
  86156. */
  86157. attribyteType: number;
  86158. /**
  86159. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86160. */
  86161. normalized: boolean;
  86162. /**
  86163. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86164. */
  86165. offset: number;
  86166. /**
  86167. * Name of the GLSL attribute, for debugging purpose only
  86168. */
  86169. attributeName: string;
  86170. }
  86171. /**
  86172. * Define options used to create a depth texture
  86173. */
  86174. export class DepthTextureCreationOptions {
  86175. /** Specifies whether or not a stencil should be allocated in the texture */
  86176. generateStencil?: boolean;
  86177. /** Specifies whether or not bilinear filtering is enable on the texture */
  86178. bilinearFiltering?: boolean;
  86179. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86180. comparisonFunction?: number;
  86181. /** Specifies if the created texture is a cube texture */
  86182. isCube?: boolean;
  86183. }
  86184. /**
  86185. * Class used to describe the capabilities of the engine relatively to the current browser
  86186. */
  86187. export class EngineCapabilities {
  86188. /** Maximum textures units per fragment shader */
  86189. maxTexturesImageUnits: number;
  86190. /** Maximum texture units per vertex shader */
  86191. maxVertexTextureImageUnits: number;
  86192. /** Maximum textures units in the entire pipeline */
  86193. maxCombinedTexturesImageUnits: number;
  86194. /** Maximum texture size */
  86195. maxTextureSize: number;
  86196. /** Maximum cube texture size */
  86197. maxCubemapTextureSize: number;
  86198. /** Maximum render texture size */
  86199. maxRenderTextureSize: number;
  86200. /** Maximum number of vertex attributes */
  86201. maxVertexAttribs: number;
  86202. /** Maximum number of varyings */
  86203. maxVaryingVectors: number;
  86204. /** Maximum number of uniforms per vertex shader */
  86205. maxVertexUniformVectors: number;
  86206. /** Maximum number of uniforms per fragment shader */
  86207. maxFragmentUniformVectors: number;
  86208. /** Defines if standard derivates (dx/dy) are supported */
  86209. standardDerivatives: boolean;
  86210. /** Defines if s3tc texture compression is supported */
  86211. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86212. /** Defines if pvrtc texture compression is supported */
  86213. pvrtc: any;
  86214. /** Defines if etc1 texture compression is supported */
  86215. etc1: any;
  86216. /** Defines if etc2 texture compression is supported */
  86217. etc2: any;
  86218. /** Defines if astc texture compression is supported */
  86219. astc: any;
  86220. /** Defines if float textures are supported */
  86221. textureFloat: boolean;
  86222. /** Defines if vertex array objects are supported */
  86223. vertexArrayObject: boolean;
  86224. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86225. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86226. /** Gets the maximum level of anisotropy supported */
  86227. maxAnisotropy: number;
  86228. /** Defines if instancing is supported */
  86229. instancedArrays: boolean;
  86230. /** Defines if 32 bits indices are supported */
  86231. uintIndices: boolean;
  86232. /** Defines if high precision shaders are supported */
  86233. highPrecisionShaderSupported: boolean;
  86234. /** Defines if depth reading in the fragment shader is supported */
  86235. fragmentDepthSupported: boolean;
  86236. /** Defines if float texture linear filtering is supported*/
  86237. textureFloatLinearFiltering: boolean;
  86238. /** Defines if rendering to float textures is supported */
  86239. textureFloatRender: boolean;
  86240. /** Defines if half float textures are supported*/
  86241. textureHalfFloat: boolean;
  86242. /** Defines if half float texture linear filtering is supported*/
  86243. textureHalfFloatLinearFiltering: boolean;
  86244. /** Defines if rendering to half float textures is supported */
  86245. textureHalfFloatRender: boolean;
  86246. /** Defines if textureLOD shader command is supported */
  86247. textureLOD: boolean;
  86248. /** Defines if draw buffers extension is supported */
  86249. drawBuffersExtension: boolean;
  86250. /** Defines if depth textures are supported */
  86251. depthTextureExtension: boolean;
  86252. /** Defines if float color buffer are supported */
  86253. colorBufferFloat: boolean;
  86254. /** Gets disjoint timer query extension (null if not supported) */
  86255. timerQuery: EXT_disjoint_timer_query;
  86256. /** Defines if timestamp can be used with timer query */
  86257. canUseTimestampForTimerQuery: boolean;
  86258. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86259. multiview: any;
  86260. /** Function used to let the system compiles shaders in background */
  86261. parallelShaderCompile: {
  86262. COMPLETION_STATUS_KHR: number;
  86263. };
  86264. }
  86265. /** Interface defining initialization parameters for Engine class */
  86266. export interface EngineOptions extends WebGLContextAttributes {
  86267. /**
  86268. * Defines if the engine should no exceed a specified device ratio
  86269. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86270. */
  86271. limitDeviceRatio?: number;
  86272. /**
  86273. * Defines if webvr should be enabled automatically
  86274. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86275. */
  86276. autoEnableWebVR?: boolean;
  86277. /**
  86278. * Defines if webgl2 should be turned off even if supported
  86279. * @see http://doc.babylonjs.com/features/webgl2
  86280. */
  86281. disableWebGL2Support?: boolean;
  86282. /**
  86283. * Defines if webaudio should be initialized as well
  86284. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86285. */
  86286. audioEngine?: boolean;
  86287. /**
  86288. * Defines if animations should run using a deterministic lock step
  86289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86290. */
  86291. deterministicLockstep?: boolean;
  86292. /** Defines the maximum steps to use with deterministic lock step mode */
  86293. lockstepMaxSteps?: number;
  86294. /**
  86295. * Defines that engine should ignore context lost events
  86296. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86297. */
  86298. doNotHandleContextLost?: boolean;
  86299. /**
  86300. * Defines that engine should ignore modifying touch action attribute and style
  86301. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86302. */
  86303. doNotHandleTouchAction?: boolean;
  86304. /**
  86305. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86306. */
  86307. useHighPrecisionFloats?: boolean;
  86308. }
  86309. /**
  86310. * Defines the interface used by display changed events
  86311. */
  86312. export interface IDisplayChangedEventArgs {
  86313. /** Gets the vrDisplay object (if any) */
  86314. vrDisplay: Nullable<any>;
  86315. /** Gets a boolean indicating if webVR is supported */
  86316. vrSupported: boolean;
  86317. }
  86318. /**
  86319. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86320. */
  86321. export class Engine {
  86322. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86323. static ExceptionList: ({
  86324. key: string;
  86325. capture: string;
  86326. captureConstraint: number;
  86327. targets: string[];
  86328. } | {
  86329. key: string;
  86330. capture: null;
  86331. captureConstraint: null;
  86332. targets: string[];
  86333. })[];
  86334. /** Gets the list of created engines */
  86335. static readonly Instances: Engine[];
  86336. /**
  86337. * Gets the latest created engine
  86338. */
  86339. static readonly LastCreatedEngine: Nullable<Engine>;
  86340. /**
  86341. * Gets the latest created scene
  86342. */
  86343. static readonly LastCreatedScene: Nullable<Scene>;
  86344. /**
  86345. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86346. * @param flag defines which part of the materials must be marked as dirty
  86347. * @param predicate defines a predicate used to filter which materials should be affected
  86348. */
  86349. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86350. /**
  86351. * Hidden
  86352. */
  86353. static _TextureLoaders: IInternalTextureLoader[];
  86354. /** Defines that alpha blending is disabled */
  86355. static readonly ALPHA_DISABLE: number;
  86356. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86357. static readonly ALPHA_ADD: number;
  86358. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86359. static readonly ALPHA_COMBINE: number;
  86360. /** Defines that alpha blending to DEST - SRC * DEST */
  86361. static readonly ALPHA_SUBTRACT: number;
  86362. /** Defines that alpha blending to SRC * DEST */
  86363. static readonly ALPHA_MULTIPLY: number;
  86364. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86365. static readonly ALPHA_MAXIMIZED: number;
  86366. /** Defines that alpha blending to SRC + DEST */
  86367. static readonly ALPHA_ONEONE: number;
  86368. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86369. static readonly ALPHA_PREMULTIPLIED: number;
  86370. /**
  86371. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86372. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86373. */
  86374. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86375. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86376. static readonly ALPHA_INTERPOLATE: number;
  86377. /**
  86378. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86379. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86380. */
  86381. static readonly ALPHA_SCREENMODE: number;
  86382. /** Defines that the ressource is not delayed*/
  86383. static readonly DELAYLOADSTATE_NONE: number;
  86384. /** Defines that the ressource was successfully delay loaded */
  86385. static readonly DELAYLOADSTATE_LOADED: number;
  86386. /** Defines that the ressource is currently delay loading */
  86387. static readonly DELAYLOADSTATE_LOADING: number;
  86388. /** Defines that the ressource is delayed and has not started loading */
  86389. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86390. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86391. static readonly NEVER: number;
  86392. /** 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 */
  86393. static readonly ALWAYS: number;
  86394. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86395. static readonly LESS: number;
  86396. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86397. static readonly EQUAL: number;
  86398. /** 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 */
  86399. static readonly LEQUAL: number;
  86400. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86401. static readonly GREATER: number;
  86402. /** 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 */
  86403. static readonly GEQUAL: number;
  86404. /** 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 */
  86405. static readonly NOTEQUAL: number;
  86406. /** Passed to stencilOperation to specify that stencil value must be kept */
  86407. static readonly KEEP: number;
  86408. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86409. static readonly REPLACE: number;
  86410. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86411. static readonly INCR: number;
  86412. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86413. static readonly DECR: number;
  86414. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86415. static readonly INVERT: number;
  86416. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86417. static readonly INCR_WRAP: number;
  86418. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86419. static readonly DECR_WRAP: number;
  86420. /** Texture is not repeating outside of 0..1 UVs */
  86421. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86422. /** Texture is repeating outside of 0..1 UVs */
  86423. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86424. /** Texture is repeating and mirrored */
  86425. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86426. /** ALPHA */
  86427. static readonly TEXTUREFORMAT_ALPHA: number;
  86428. /** LUMINANCE */
  86429. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86430. /** LUMINANCE_ALPHA */
  86431. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86432. /** RGB */
  86433. static readonly TEXTUREFORMAT_RGB: number;
  86434. /** RGBA */
  86435. static readonly TEXTUREFORMAT_RGBA: number;
  86436. /** RED */
  86437. static readonly TEXTUREFORMAT_RED: number;
  86438. /** RED (2nd reference) */
  86439. static readonly TEXTUREFORMAT_R: number;
  86440. /** RG */
  86441. static readonly TEXTUREFORMAT_RG: number;
  86442. /** RED_INTEGER */
  86443. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86444. /** RED_INTEGER (2nd reference) */
  86445. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86446. /** RG_INTEGER */
  86447. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86448. /** RGB_INTEGER */
  86449. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86450. /** RGBA_INTEGER */
  86451. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86452. /** UNSIGNED_BYTE */
  86453. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86454. /** UNSIGNED_BYTE (2nd reference) */
  86455. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86456. /** FLOAT */
  86457. static readonly TEXTURETYPE_FLOAT: number;
  86458. /** HALF_FLOAT */
  86459. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86460. /** BYTE */
  86461. static readonly TEXTURETYPE_BYTE: number;
  86462. /** SHORT */
  86463. static readonly TEXTURETYPE_SHORT: number;
  86464. /** UNSIGNED_SHORT */
  86465. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86466. /** INT */
  86467. static readonly TEXTURETYPE_INT: number;
  86468. /** UNSIGNED_INT */
  86469. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86470. /** UNSIGNED_SHORT_4_4_4_4 */
  86471. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86472. /** UNSIGNED_SHORT_5_5_5_1 */
  86473. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86474. /** UNSIGNED_SHORT_5_6_5 */
  86475. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86476. /** UNSIGNED_INT_2_10_10_10_REV */
  86477. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86478. /** UNSIGNED_INT_24_8 */
  86479. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86480. /** UNSIGNED_INT_10F_11F_11F_REV */
  86481. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86482. /** UNSIGNED_INT_5_9_9_9_REV */
  86483. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86484. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86485. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86486. /** nearest is mag = nearest and min = nearest and mip = linear */
  86487. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86488. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86489. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86490. /** Trilinear is mag = linear and min = linear and mip = linear */
  86491. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86492. /** nearest is mag = nearest and min = nearest and mip = linear */
  86493. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86494. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86495. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86496. /** Trilinear is mag = linear and min = linear and mip = linear */
  86497. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86498. /** mag = nearest and min = nearest and mip = nearest */
  86499. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86500. /** mag = nearest and min = linear and mip = nearest */
  86501. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86502. /** mag = nearest and min = linear and mip = linear */
  86503. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86504. /** mag = nearest and min = linear and mip = none */
  86505. static readonly TEXTURE_NEAREST_LINEAR: number;
  86506. /** mag = nearest and min = nearest and mip = none */
  86507. static readonly TEXTURE_NEAREST_NEAREST: number;
  86508. /** mag = linear and min = nearest and mip = nearest */
  86509. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86510. /** mag = linear and min = nearest and mip = linear */
  86511. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86512. /** mag = linear and min = linear and mip = none */
  86513. static readonly TEXTURE_LINEAR_LINEAR: number;
  86514. /** mag = linear and min = nearest and mip = none */
  86515. static readonly TEXTURE_LINEAR_NEAREST: number;
  86516. /** Explicit coordinates mode */
  86517. static readonly TEXTURE_EXPLICIT_MODE: number;
  86518. /** Spherical coordinates mode */
  86519. static readonly TEXTURE_SPHERICAL_MODE: number;
  86520. /** Planar coordinates mode */
  86521. static readonly TEXTURE_PLANAR_MODE: number;
  86522. /** Cubic coordinates mode */
  86523. static readonly TEXTURE_CUBIC_MODE: number;
  86524. /** Projection coordinates mode */
  86525. static readonly TEXTURE_PROJECTION_MODE: number;
  86526. /** Skybox coordinates mode */
  86527. static readonly TEXTURE_SKYBOX_MODE: number;
  86528. /** Inverse Cubic coordinates mode */
  86529. static readonly TEXTURE_INVCUBIC_MODE: number;
  86530. /** Equirectangular coordinates mode */
  86531. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86532. /** Equirectangular Fixed coordinates mode */
  86533. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86534. /** Equirectangular Fixed Mirrored coordinates mode */
  86535. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86536. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86537. static readonly SCALEMODE_FLOOR: number;
  86538. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86539. static readonly SCALEMODE_NEAREST: number;
  86540. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86541. static readonly SCALEMODE_CEILING: number;
  86542. /**
  86543. * Returns the current npm package of the sdk
  86544. */
  86545. static readonly NpmPackage: string;
  86546. /**
  86547. * Returns the current version of the framework
  86548. */
  86549. static readonly Version: string;
  86550. /**
  86551. * Returns a string describing the current engine
  86552. */
  86553. readonly description: string;
  86554. /**
  86555. * Gets or sets the epsilon value used by collision engine
  86556. */
  86557. static CollisionsEpsilon: number;
  86558. /**
  86559. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86560. */
  86561. static ShadersRepository: string;
  86562. /**
  86563. * Method called to create the default loading screen.
  86564. * This can be overriden in your own app.
  86565. * @param canvas The rendering canvas element
  86566. * @returns The loading screen
  86567. */
  86568. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86569. /**
  86570. * Method called to create the default rescale post process on each engine.
  86571. */
  86572. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86573. /**
  86574. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86575. */
  86576. forcePOTTextures: boolean;
  86577. /**
  86578. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86579. */
  86580. isFullscreen: boolean;
  86581. /**
  86582. * Gets a boolean indicating if the pointer is currently locked
  86583. */
  86584. isPointerLock: boolean;
  86585. /**
  86586. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86587. */
  86588. cullBackFaces: boolean;
  86589. /**
  86590. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86591. */
  86592. renderEvenInBackground: boolean;
  86593. /**
  86594. * Gets or sets a boolean indicating that cache can be kept between frames
  86595. */
  86596. preventCacheWipeBetweenFrames: boolean;
  86597. /**
  86598. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86599. **/
  86600. enableOfflineSupport: boolean;
  86601. /**
  86602. * 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)
  86603. **/
  86604. disableManifestCheck: boolean;
  86605. /**
  86606. * Gets the list of created scenes
  86607. */
  86608. scenes: Scene[];
  86609. /**
  86610. * Event raised when a new scene is created
  86611. */
  86612. onNewSceneAddedObservable: Observable<Scene>;
  86613. /**
  86614. * Gets the list of created postprocesses
  86615. */
  86616. postProcesses: PostProcess[];
  86617. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86618. validateShaderPrograms: boolean;
  86619. /**
  86620. * Observable event triggered each time the rendering canvas is resized
  86621. */
  86622. onResizeObservable: Observable<Engine>;
  86623. /**
  86624. * Observable event triggered each time the canvas loses focus
  86625. */
  86626. onCanvasBlurObservable: Observable<Engine>;
  86627. /**
  86628. * Observable event triggered each time the canvas gains focus
  86629. */
  86630. onCanvasFocusObservable: Observable<Engine>;
  86631. /**
  86632. * Observable event triggered each time the canvas receives pointerout event
  86633. */
  86634. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86635. /**
  86636. * Observable event triggered before each texture is initialized
  86637. */
  86638. onBeforeTextureInitObservable: Observable<Texture>;
  86639. private _vrDisplay;
  86640. private _vrSupported;
  86641. private _oldSize;
  86642. private _oldHardwareScaleFactor;
  86643. private _vrExclusivePointerMode;
  86644. private _webVRInitPromise;
  86645. /**
  86646. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86647. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86648. */
  86649. readonly isInVRExclusivePointerMode: boolean;
  86650. /**
  86651. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86652. */
  86653. disableUniformBuffers: boolean;
  86654. /** @hidden */
  86655. _uniformBuffers: UniformBuffer[];
  86656. /**
  86657. * Gets a boolean indicating that the engine supports uniform buffers
  86658. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86659. */
  86660. readonly supportsUniformBuffers: boolean;
  86661. /**
  86662. * Observable raised when the engine begins a new frame
  86663. */
  86664. onBeginFrameObservable: Observable<Engine>;
  86665. /**
  86666. * If set, will be used to request the next animation frame for the render loop
  86667. */
  86668. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86669. /**
  86670. * Observable raised when the engine ends the current frame
  86671. */
  86672. onEndFrameObservable: Observable<Engine>;
  86673. /**
  86674. * Observable raised when the engine is about to compile a shader
  86675. */
  86676. onBeforeShaderCompilationObservable: Observable<Engine>;
  86677. /**
  86678. * Observable raised when the engine has jsut compiled a shader
  86679. */
  86680. onAfterShaderCompilationObservable: Observable<Engine>;
  86681. /** @hidden */
  86682. _gl: WebGLRenderingContext;
  86683. private _renderingCanvas;
  86684. private _windowIsBackground;
  86685. private _webGLVersion;
  86686. protected _highPrecisionShadersAllowed: boolean;
  86687. /** @hidden */
  86688. readonly _shouldUseHighPrecisionShader: boolean;
  86689. /**
  86690. * Gets a boolean indicating that only power of 2 textures are supported
  86691. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86692. */
  86693. readonly needPOTTextures: boolean;
  86694. /** @hidden */
  86695. _badOS: boolean;
  86696. /** @hidden */
  86697. _badDesktopOS: boolean;
  86698. /**
  86699. * Gets the audio engine
  86700. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86701. * @ignorenaming
  86702. */
  86703. static audioEngine: IAudioEngine;
  86704. /**
  86705. * Default AudioEngine factory responsible of creating the Audio Engine.
  86706. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86707. */
  86708. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86709. /**
  86710. * Default offline support factory responsible of creating a tool used to store data locally.
  86711. * By default, this will create a Database object if the workload has been embedded.
  86712. */
  86713. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86714. private _onFocus;
  86715. private _onBlur;
  86716. private _onCanvasPointerOut;
  86717. private _onCanvasBlur;
  86718. private _onCanvasFocus;
  86719. private _onFullscreenChange;
  86720. private _onPointerLockChange;
  86721. private _onVRDisplayPointerRestricted;
  86722. private _onVRDisplayPointerUnrestricted;
  86723. private _onVrDisplayConnect;
  86724. private _onVrDisplayDisconnect;
  86725. private _onVrDisplayPresentChange;
  86726. /**
  86727. * Observable signaled when VR display mode changes
  86728. */
  86729. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  86730. /**
  86731. * Observable signaled when VR request present is complete
  86732. */
  86733. onVRRequestPresentComplete: Observable<boolean>;
  86734. /**
  86735. * Observable signaled when VR request present starts
  86736. */
  86737. onVRRequestPresentStart: Observable<Engine>;
  86738. private _hardwareScalingLevel;
  86739. /** @hidden */
  86740. protected _caps: EngineCapabilities;
  86741. private _pointerLockRequested;
  86742. private _isStencilEnable;
  86743. private _colorWrite;
  86744. private _loadingScreen;
  86745. /** @hidden */
  86746. _drawCalls: PerfCounter;
  86747. private _glVersion;
  86748. private _glRenderer;
  86749. private _glVendor;
  86750. private _videoTextureSupported;
  86751. private _renderingQueueLaunched;
  86752. private _activeRenderLoops;
  86753. private _deterministicLockstep;
  86754. private _lockstepMaxSteps;
  86755. /**
  86756. * Observable signaled when a context lost event is raised
  86757. */
  86758. onContextLostObservable: Observable<Engine>;
  86759. /**
  86760. * Observable signaled when a context restored event is raised
  86761. */
  86762. onContextRestoredObservable: Observable<Engine>;
  86763. private _onContextLost;
  86764. private _onContextRestored;
  86765. private _contextWasLost;
  86766. private _doNotHandleContextLost;
  86767. /**
  86768. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  86769. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  86770. */
  86771. doNotHandleContextLost: boolean;
  86772. private _performanceMonitor;
  86773. private _fps;
  86774. private _deltaTime;
  86775. /**
  86776. * Turn this value on if you want to pause FPS computation when in background
  86777. */
  86778. disablePerformanceMonitorInBackground: boolean;
  86779. /**
  86780. * Gets the performance monitor attached to this engine
  86781. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  86782. */
  86783. readonly performanceMonitor: PerformanceMonitor;
  86784. /**
  86785. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  86786. */
  86787. disableVertexArrayObjects: boolean;
  86788. /** @hidden */
  86789. protected _depthCullingState: _DepthCullingState;
  86790. /** @hidden */
  86791. protected _stencilState: _StencilState;
  86792. /** @hidden */
  86793. protected _alphaState: _AlphaState;
  86794. /** @hidden */
  86795. protected _alphaMode: number;
  86796. protected _internalTexturesCache: InternalTexture[];
  86797. /** @hidden */
  86798. protected _activeChannel: number;
  86799. private _currentTextureChannel;
  86800. /** @hidden */
  86801. protected _boundTexturesCache: {
  86802. [key: string]: Nullable<InternalTexture>;
  86803. };
  86804. /** @hidden */
  86805. protected _currentEffect: Nullable<Effect>;
  86806. /** @hidden */
  86807. protected _currentProgram: Nullable<WebGLProgram>;
  86808. private _compiledEffects;
  86809. private _vertexAttribArraysEnabled;
  86810. /** @hidden */
  86811. protected _cachedViewport: Nullable<Viewport>;
  86812. private _cachedVertexArrayObject;
  86813. /** @hidden */
  86814. protected _cachedVertexBuffers: any;
  86815. /** @hidden */
  86816. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  86817. /** @hidden */
  86818. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  86819. /** @hidden */
  86820. protected _currentRenderTarget: Nullable<InternalTexture>;
  86821. private _uintIndicesCurrentlySet;
  86822. private _currentBoundBuffer;
  86823. /** @hidden */
  86824. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  86825. private _currentBufferPointers;
  86826. private _currentInstanceLocations;
  86827. private _currentInstanceBuffers;
  86828. private _textureUnits;
  86829. private _workingCanvas;
  86830. private _workingContext;
  86831. private _rescalePostProcess;
  86832. private _dummyFramebuffer;
  86833. private _externalData;
  86834. private _bindedRenderFunction;
  86835. private _vaoRecordInProgress;
  86836. private _mustWipeVertexAttributes;
  86837. private _emptyTexture;
  86838. private _emptyCubeTexture;
  86839. private _emptyTexture3D;
  86840. /** @hidden */
  86841. _frameHandler: number;
  86842. private _nextFreeTextureSlots;
  86843. private _maxSimultaneousTextures;
  86844. private _activeRequests;
  86845. private _texturesSupported;
  86846. private _textureFormatInUse;
  86847. /**
  86848. * Gets the list of texture formats supported
  86849. */
  86850. readonly texturesSupported: Array<string>;
  86851. /**
  86852. * Gets the list of texture formats in use
  86853. */
  86854. readonly textureFormatInUse: Nullable<string>;
  86855. /**
  86856. * Gets the current viewport
  86857. */
  86858. readonly currentViewport: Nullable<Viewport>;
  86859. /**
  86860. * Gets the default empty texture
  86861. */
  86862. readonly emptyTexture: InternalTexture;
  86863. /**
  86864. * Gets the default empty 3D texture
  86865. */
  86866. readonly emptyTexture3D: InternalTexture;
  86867. /**
  86868. * Gets the default empty cube texture
  86869. */
  86870. readonly emptyCubeTexture: InternalTexture;
  86871. /**
  86872. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  86873. */
  86874. readonly premultipliedAlpha: boolean;
  86875. /**
  86876. * Creates a new engine
  86877. * @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
  86878. * @param antialias defines enable antialiasing (default: false)
  86879. * @param options defines further options to be sent to the getContext() function
  86880. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  86881. */
  86882. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  86883. private _disableTouchAction;
  86884. private _rebuildInternalTextures;
  86885. private _rebuildEffects;
  86886. /**
  86887. * Gets a boolean indicating if all created effects are ready
  86888. * @returns true if all effects are ready
  86889. */
  86890. areAllEffectsReady(): boolean;
  86891. private _rebuildBuffers;
  86892. private _initGLContext;
  86893. /**
  86894. * Gets version of the current webGL context
  86895. */
  86896. readonly webGLVersion: number;
  86897. /**
  86898. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  86899. */
  86900. readonly isStencilEnable: boolean;
  86901. private _prepareWorkingCanvas;
  86902. /**
  86903. * Reset the texture cache to empty state
  86904. */
  86905. resetTextureCache(): void;
  86906. /**
  86907. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  86908. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86909. * @returns true if engine is in deterministic lock step mode
  86910. */
  86911. isDeterministicLockStep(): boolean;
  86912. /**
  86913. * Gets the max steps when engine is running in deterministic lock step
  86914. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86915. * @returns the max steps
  86916. */
  86917. getLockstepMaxSteps(): number;
  86918. /**
  86919. * Gets an object containing information about the current webGL context
  86920. * @returns an object containing the vender, the renderer and the version of the current webGL context
  86921. */
  86922. getGlInfo(): {
  86923. vendor: string;
  86924. renderer: string;
  86925. version: string;
  86926. };
  86927. /**
  86928. * Gets current aspect ratio
  86929. * @param camera defines the camera to use to get the aspect ratio
  86930. * @param useScreen defines if screen size must be used (or the current render target if any)
  86931. * @returns a number defining the aspect ratio
  86932. */
  86933. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  86934. /**
  86935. * Gets current screen aspect ratio
  86936. * @returns a number defining the aspect ratio
  86937. */
  86938. getScreenAspectRatio(): number;
  86939. /**
  86940. * Gets the current render width
  86941. * @param useScreen defines if screen size must be used (or the current render target if any)
  86942. * @returns a number defining the current render width
  86943. */
  86944. getRenderWidth(useScreen?: boolean): number;
  86945. /**
  86946. * Gets the current render height
  86947. * @param useScreen defines if screen size must be used (or the current render target if any)
  86948. * @returns a number defining the current render height
  86949. */
  86950. getRenderHeight(useScreen?: boolean): number;
  86951. /**
  86952. * Gets the HTML canvas attached with the current webGL context
  86953. * @returns a HTML canvas
  86954. */
  86955. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  86956. /**
  86957. * Gets the client rect of the HTML canvas attached with the current webGL context
  86958. * @returns a client rectanglee
  86959. */
  86960. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  86961. /**
  86962. * Defines the hardware scaling level.
  86963. * By default the hardware scaling level is computed from the window device ratio.
  86964. * 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.
  86965. * @param level defines the level to use
  86966. */
  86967. setHardwareScalingLevel(level: number): void;
  86968. /**
  86969. * Gets the current hardware scaling level.
  86970. * By default the hardware scaling level is computed from the window device ratio.
  86971. * 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.
  86972. * @returns a number indicating the current hardware scaling level
  86973. */
  86974. getHardwareScalingLevel(): number;
  86975. /**
  86976. * Gets the list of loaded textures
  86977. * @returns an array containing all loaded textures
  86978. */
  86979. getLoadedTexturesCache(): InternalTexture[];
  86980. /**
  86981. * Gets the object containing all engine capabilities
  86982. * @returns the EngineCapabilities object
  86983. */
  86984. getCaps(): EngineCapabilities;
  86985. /**
  86986. * Gets the current depth function
  86987. * @returns a number defining the depth function
  86988. */
  86989. getDepthFunction(): Nullable<number>;
  86990. /**
  86991. * Sets the current depth function
  86992. * @param depthFunc defines the function to use
  86993. */
  86994. setDepthFunction(depthFunc: number): void;
  86995. /**
  86996. * Sets the current depth function to GREATER
  86997. */
  86998. setDepthFunctionToGreater(): void;
  86999. /**
  87000. * Sets the current depth function to GEQUAL
  87001. */
  87002. setDepthFunctionToGreaterOrEqual(): void;
  87003. /**
  87004. * Sets the current depth function to LESS
  87005. */
  87006. setDepthFunctionToLess(): void;
  87007. private _cachedStencilBuffer;
  87008. private _cachedStencilFunction;
  87009. private _cachedStencilMask;
  87010. private _cachedStencilOperationPass;
  87011. private _cachedStencilOperationFail;
  87012. private _cachedStencilOperationDepthFail;
  87013. private _cachedStencilReference;
  87014. /**
  87015. * Caches the the state of the stencil buffer
  87016. */
  87017. cacheStencilState(): void;
  87018. /**
  87019. * Restores the state of the stencil buffer
  87020. */
  87021. restoreStencilState(): void;
  87022. /**
  87023. * Sets the current depth function to LEQUAL
  87024. */
  87025. setDepthFunctionToLessOrEqual(): void;
  87026. /**
  87027. * Gets a boolean indicating if stencil buffer is enabled
  87028. * @returns the current stencil buffer state
  87029. */
  87030. getStencilBuffer(): boolean;
  87031. /**
  87032. * Enable or disable the stencil buffer
  87033. * @param enable defines if the stencil buffer must be enabled or disabled
  87034. */
  87035. setStencilBuffer(enable: boolean): void;
  87036. /**
  87037. * Gets the current stencil mask
  87038. * @returns a number defining the new stencil mask to use
  87039. */
  87040. getStencilMask(): number;
  87041. /**
  87042. * Sets the current stencil mask
  87043. * @param mask defines the new stencil mask to use
  87044. */
  87045. setStencilMask(mask: number): void;
  87046. /**
  87047. * Gets the current stencil function
  87048. * @returns a number defining the stencil function to use
  87049. */
  87050. getStencilFunction(): number;
  87051. /**
  87052. * Gets the current stencil reference value
  87053. * @returns a number defining the stencil reference value to use
  87054. */
  87055. getStencilFunctionReference(): number;
  87056. /**
  87057. * Gets the current stencil mask
  87058. * @returns a number defining the stencil mask to use
  87059. */
  87060. getStencilFunctionMask(): number;
  87061. /**
  87062. * Sets the current stencil function
  87063. * @param stencilFunc defines the new stencil function to use
  87064. */
  87065. setStencilFunction(stencilFunc: number): void;
  87066. /**
  87067. * Sets the current stencil reference
  87068. * @param reference defines the new stencil reference to use
  87069. */
  87070. setStencilFunctionReference(reference: number): void;
  87071. /**
  87072. * Sets the current stencil mask
  87073. * @param mask defines the new stencil mask to use
  87074. */
  87075. setStencilFunctionMask(mask: number): void;
  87076. /**
  87077. * Gets the current stencil operation when stencil fails
  87078. * @returns a number defining stencil operation to use when stencil fails
  87079. */
  87080. getStencilOperationFail(): number;
  87081. /**
  87082. * Gets the current stencil operation when depth fails
  87083. * @returns a number defining stencil operation to use when depth fails
  87084. */
  87085. getStencilOperationDepthFail(): number;
  87086. /**
  87087. * Gets the current stencil operation when stencil passes
  87088. * @returns a number defining stencil operation to use when stencil passes
  87089. */
  87090. getStencilOperationPass(): number;
  87091. /**
  87092. * Sets the stencil operation to use when stencil fails
  87093. * @param operation defines the stencil operation to use when stencil fails
  87094. */
  87095. setStencilOperationFail(operation: number): void;
  87096. /**
  87097. * Sets the stencil operation to use when depth fails
  87098. * @param operation defines the stencil operation to use when depth fails
  87099. */
  87100. setStencilOperationDepthFail(operation: number): void;
  87101. /**
  87102. * Sets the stencil operation to use when stencil passes
  87103. * @param operation defines the stencil operation to use when stencil passes
  87104. */
  87105. setStencilOperationPass(operation: number): void;
  87106. /**
  87107. * Sets a boolean indicating if the dithering state is enabled or disabled
  87108. * @param value defines the dithering state
  87109. */
  87110. setDitheringState(value: boolean): void;
  87111. /**
  87112. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87113. * @param value defines the rasterizer state
  87114. */
  87115. setRasterizerState(value: boolean): void;
  87116. /**
  87117. * stop executing a render loop function and remove it from the execution array
  87118. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87119. */
  87120. stopRenderLoop(renderFunction?: () => void): void;
  87121. /** @hidden */
  87122. _renderLoop(): void;
  87123. /**
  87124. * Register and execute a render loop. The engine can have more than one render function
  87125. * @param renderFunction defines the function to continuously execute
  87126. */
  87127. runRenderLoop(renderFunction: () => void): void;
  87128. /**
  87129. * Toggle full screen mode
  87130. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87131. */
  87132. switchFullscreen(requestPointerLock: boolean): void;
  87133. /**
  87134. * Enters full screen mode
  87135. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87136. */
  87137. enterFullscreen(requestPointerLock: boolean): void;
  87138. /**
  87139. * Exits full screen mode
  87140. */
  87141. exitFullscreen(): void;
  87142. /**
  87143. * Clear the current render buffer or the current render target (if any is set up)
  87144. * @param color defines the color to use
  87145. * @param backBuffer defines if the back buffer must be cleared
  87146. * @param depth defines if the depth buffer must be cleared
  87147. * @param stencil defines if the stencil buffer must be cleared
  87148. */
  87149. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87150. /**
  87151. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87152. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87153. * @param y defines the y-coordinate of the corner of the clear rectangle
  87154. * @param width defines the width of the clear rectangle
  87155. * @param height defines the height of the clear rectangle
  87156. * @param clearColor defines the clear color
  87157. */
  87158. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87159. /**
  87160. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87161. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87162. * @param y defines the y-coordinate of the corner of the clear rectangle
  87163. * @param width defines the width of the clear rectangle
  87164. * @param height defines the height of the clear rectangle
  87165. */
  87166. enableScissor(x: number, y: number, width: number, height: number): void;
  87167. /**
  87168. * Disable previously set scissor test rectangle
  87169. */
  87170. disableScissor(): void;
  87171. private _viewportCached;
  87172. /** @hidden */
  87173. _viewport(x: number, y: number, width: number, height: number): void;
  87174. /**
  87175. * Set the WebGL's viewport
  87176. * @param viewport defines the viewport element to be used
  87177. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87178. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87179. */
  87180. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87181. /**
  87182. * Directly set the WebGL Viewport
  87183. * @param x defines the x coordinate of the viewport (in screen space)
  87184. * @param y defines the y coordinate of the viewport (in screen space)
  87185. * @param width defines the width of the viewport (in screen space)
  87186. * @param height defines the height of the viewport (in screen space)
  87187. * @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
  87188. */
  87189. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87190. /**
  87191. * Begin a new frame
  87192. */
  87193. beginFrame(): void;
  87194. /**
  87195. * Enf the current frame
  87196. */
  87197. endFrame(): void;
  87198. /**
  87199. * Resize the view according to the canvas' size
  87200. */
  87201. resize(): void;
  87202. /**
  87203. * Force a specific size of the canvas
  87204. * @param width defines the new canvas' width
  87205. * @param height defines the new canvas' height
  87206. */
  87207. setSize(width: number, height: number): void;
  87208. /**
  87209. * Gets a boolean indicating if a webVR device was detected
  87210. * @returns true if a webVR device was detected
  87211. */
  87212. isVRDevicePresent(): boolean;
  87213. /**
  87214. * Gets the current webVR device
  87215. * @returns the current webVR device (or null)
  87216. */
  87217. getVRDevice(): any;
  87218. /**
  87219. * Initializes a webVR display and starts listening to display change events
  87220. * The onVRDisplayChangedObservable will be notified upon these changes
  87221. * @returns The onVRDisplayChangedObservable
  87222. */
  87223. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87224. /**
  87225. * Initializes a webVR display and starts listening to display change events
  87226. * The onVRDisplayChangedObservable will be notified upon these changes
  87227. * @returns A promise containing a VRDisplay and if vr is supported
  87228. */
  87229. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87230. /**
  87231. * Call this function to switch to webVR mode
  87232. * Will do nothing if webVR is not supported or if there is no webVR device
  87233. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87234. */
  87235. enableVR(): void;
  87236. /**
  87237. * Call this function to leave webVR mode
  87238. * Will do nothing if webVR is not supported or if there is no webVR device
  87239. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87240. */
  87241. disableVR(): void;
  87242. private _onVRFullScreenTriggered;
  87243. private _getVRDisplaysAsync;
  87244. /**
  87245. * Binds the frame buffer to the specified texture.
  87246. * @param texture The texture to render to or null for the default canvas
  87247. * @param faceIndex The face of the texture to render to in case of cube texture
  87248. * @param requiredWidth The width of the target to render to
  87249. * @param requiredHeight The height of the target to render to
  87250. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87251. * @param depthStencilTexture The depth stencil texture to use to render
  87252. * @param lodLevel defines le lod level to bind to the frame buffer
  87253. */
  87254. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87255. private bindUnboundFramebuffer;
  87256. /**
  87257. * Unbind the current render target texture from the webGL context
  87258. * @param texture defines the render target texture to unbind
  87259. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87260. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87261. */
  87262. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87263. /**
  87264. * Unbind a list of render target textures from the webGL context
  87265. * This is used only when drawBuffer extension or webGL2 are active
  87266. * @param textures defines the render target textures to unbind
  87267. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87268. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87269. */
  87270. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87271. /**
  87272. * Force the mipmap generation for the given render target texture
  87273. * @param texture defines the render target texture to use
  87274. */
  87275. generateMipMapsForCubemap(texture: InternalTexture): void;
  87276. /**
  87277. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87278. */
  87279. flushFramebuffer(): void;
  87280. /**
  87281. * Unbind the current render target and bind the default framebuffer
  87282. */
  87283. restoreDefaultFramebuffer(): void;
  87284. /**
  87285. * Create an uniform buffer
  87286. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87287. * @param elements defines the content of the uniform buffer
  87288. * @returns the webGL uniform buffer
  87289. */
  87290. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87291. /**
  87292. * Create a dynamic uniform buffer
  87293. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87294. * @param elements defines the content of the uniform buffer
  87295. * @returns the webGL uniform buffer
  87296. */
  87297. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87298. /**
  87299. * Update an existing uniform buffer
  87300. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87301. * @param uniformBuffer defines the target uniform buffer
  87302. * @param elements defines the content to update
  87303. * @param offset defines the offset in the uniform buffer where update should start
  87304. * @param count defines the size of the data to update
  87305. */
  87306. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87307. private _resetVertexBufferBinding;
  87308. /**
  87309. * Creates a vertex buffer
  87310. * @param data the data for the vertex buffer
  87311. * @returns the new WebGL static buffer
  87312. */
  87313. createVertexBuffer(data: DataArray): WebGLBuffer;
  87314. /**
  87315. * Creates a dynamic vertex buffer
  87316. * @param data the data for the dynamic vertex buffer
  87317. * @returns the new WebGL dynamic buffer
  87318. */
  87319. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87320. /**
  87321. * Update a dynamic index buffer
  87322. * @param indexBuffer defines the target index buffer
  87323. * @param indices defines the data to update
  87324. * @param offset defines the offset in the target index buffer where update should start
  87325. */
  87326. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87327. /**
  87328. * Updates a dynamic vertex buffer.
  87329. * @param vertexBuffer the vertex buffer to update
  87330. * @param data the data used to update the vertex buffer
  87331. * @param byteOffset the byte offset of the data
  87332. * @param byteLength the byte length of the data
  87333. */
  87334. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87335. private _resetIndexBufferBinding;
  87336. /**
  87337. * Creates a new index buffer
  87338. * @param indices defines the content of the index buffer
  87339. * @param updatable defines if the index buffer must be updatable
  87340. * @returns a new webGL buffer
  87341. */
  87342. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87343. /**
  87344. * Bind a webGL buffer to the webGL context
  87345. * @param buffer defines the buffer to bind
  87346. */
  87347. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87348. /**
  87349. * Bind an uniform buffer to the current webGL context
  87350. * @param buffer defines the buffer to bind
  87351. */
  87352. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87353. /**
  87354. * Bind a buffer to the current webGL context at a given location
  87355. * @param buffer defines the buffer to bind
  87356. * @param location defines the index where to bind the buffer
  87357. */
  87358. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87359. /**
  87360. * Bind a specific block at a given index in a specific shader program
  87361. * @param shaderProgram defines the shader program
  87362. * @param blockName defines the block name
  87363. * @param index defines the index where to bind the block
  87364. */
  87365. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87366. private bindIndexBuffer;
  87367. private bindBuffer;
  87368. /**
  87369. * update the bound buffer with the given data
  87370. * @param data defines the data to update
  87371. */
  87372. updateArrayBuffer(data: Float32Array): void;
  87373. private _vertexAttribPointer;
  87374. private _bindIndexBufferWithCache;
  87375. private _bindVertexBuffersAttributes;
  87376. /**
  87377. * Records a vertex array object
  87378. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87379. * @param vertexBuffers defines the list of vertex buffers to store
  87380. * @param indexBuffer defines the index buffer to store
  87381. * @param effect defines the effect to store
  87382. * @returns the new vertex array object
  87383. */
  87384. recordVertexArrayObject(vertexBuffers: {
  87385. [key: string]: VertexBuffer;
  87386. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87387. /**
  87388. * Bind a specific vertex array object
  87389. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87390. * @param vertexArrayObject defines the vertex array object to bind
  87391. * @param indexBuffer defines the index buffer to bind
  87392. */
  87393. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87394. /**
  87395. * Bind webGl buffers directly to the webGL context
  87396. * @param vertexBuffer defines the vertex buffer to bind
  87397. * @param indexBuffer defines the index buffer to bind
  87398. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87399. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87400. * @param effect defines the effect associated with the vertex buffer
  87401. */
  87402. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87403. private _unbindVertexArrayObject;
  87404. /**
  87405. * Bind a list of vertex buffers to the webGL context
  87406. * @param vertexBuffers defines the list of vertex buffers to bind
  87407. * @param indexBuffer defines the index buffer to bind
  87408. * @param effect defines the effect associated with the vertex buffers
  87409. */
  87410. bindBuffers(vertexBuffers: {
  87411. [key: string]: Nullable<VertexBuffer>;
  87412. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87413. /**
  87414. * Unbind all instance attributes
  87415. */
  87416. unbindInstanceAttributes(): void;
  87417. /**
  87418. * Release and free the memory of a vertex array object
  87419. * @param vao defines the vertex array object to delete
  87420. */
  87421. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87422. /** @hidden */
  87423. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87424. /**
  87425. * Creates a webGL buffer to use with instanciation
  87426. * @param capacity defines the size of the buffer
  87427. * @returns the webGL buffer
  87428. */
  87429. createInstancesBuffer(capacity: number): WebGLBuffer;
  87430. /**
  87431. * Delete a webGL buffer used with instanciation
  87432. * @param buffer defines the webGL buffer to delete
  87433. */
  87434. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87435. /**
  87436. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87437. * @param instancesBuffer defines the webGL buffer to update and bind
  87438. * @param data defines the data to store in the buffer
  87439. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87440. */
  87441. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87442. /**
  87443. * Apply all cached states (depth, culling, stencil and alpha)
  87444. */
  87445. applyStates(): void;
  87446. /**
  87447. * Send a draw order
  87448. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87449. * @param indexStart defines the starting index
  87450. * @param indexCount defines the number of index to draw
  87451. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87452. */
  87453. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87454. /**
  87455. * Draw a list of points
  87456. * @param verticesStart defines the index of first vertex to draw
  87457. * @param verticesCount defines the count of vertices to draw
  87458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87459. */
  87460. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87461. /**
  87462. * Draw a list of unindexed primitives
  87463. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87464. * @param verticesStart defines the index of first vertex to draw
  87465. * @param verticesCount defines the count of vertices to draw
  87466. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87467. */
  87468. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87469. /**
  87470. * Draw a list of indexed primitives
  87471. * @param fillMode defines the primitive to use
  87472. * @param indexStart defines the starting index
  87473. * @param indexCount defines the number of index to draw
  87474. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87475. */
  87476. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87477. /**
  87478. * Draw a list of unindexed primitives
  87479. * @param fillMode defines the primitive to use
  87480. * @param verticesStart defines the index of first vertex to draw
  87481. * @param verticesCount defines the count of vertices to draw
  87482. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87483. */
  87484. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87485. private _drawMode;
  87486. /** @hidden */
  87487. _releaseEffect(effect: Effect): void;
  87488. /** @hidden */
  87489. _deleteProgram(program: WebGLProgram): void;
  87490. /**
  87491. * Create a new effect (used to store vertex/fragment shaders)
  87492. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87493. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87494. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87495. * @param samplers defines an array of string used to represent textures
  87496. * @param defines defines the string containing the defines to use to compile the shaders
  87497. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87498. * @param onCompiled defines a function to call when the effect creation is successful
  87499. * @param onError defines a function to call when the effect creation has failed
  87500. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87501. * @returns the new Effect
  87502. */
  87503. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  87504. private _compileShader;
  87505. private _compileRawShader;
  87506. /**
  87507. * Directly creates a webGL program
  87508. * @param vertexCode defines the vertex shader code to use
  87509. * @param fragmentCode defines the fragment shader code to use
  87510. * @param context defines the webGL context to use (if not set, the current one will be used)
  87511. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87512. * @returns the new webGL program
  87513. */
  87514. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87515. /**
  87516. * Creates a webGL program
  87517. * @param vertexCode defines the vertex shader code to use
  87518. * @param fragmentCode defines the fragment shader code to use
  87519. * @param defines defines the string containing the defines to use to compile the shaders
  87520. * @param context defines the webGL context to use (if not set, the current one will be used)
  87521. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87522. * @returns the new webGL program
  87523. */
  87524. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87525. private _createShaderProgram;
  87526. private _finalizeProgram;
  87527. /** @hidden */
  87528. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87529. /** @hidden */
  87530. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87531. /**
  87532. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87533. * @param shaderProgram defines the webGL program to use
  87534. * @param uniformsNames defines the list of uniform names
  87535. * @returns an array of webGL uniform locations
  87536. */
  87537. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87538. /**
  87539. * Gets the lsit of active attributes for a given webGL program
  87540. * @param shaderProgram defines the webGL program to use
  87541. * @param attributesNames defines the list of attribute names to get
  87542. * @returns an array of indices indicating the offset of each attribute
  87543. */
  87544. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87545. /**
  87546. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87547. * @param effect defines the effect to activate
  87548. */
  87549. enableEffect(effect: Nullable<Effect>): void;
  87550. /**
  87551. * Set the value of an uniform to an array of int32
  87552. * @param uniform defines the webGL uniform location where to store the value
  87553. * @param array defines the array of int32 to store
  87554. */
  87555. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87556. /**
  87557. * Set the value of an uniform to an array of int32 (stored as vec2)
  87558. * @param uniform defines the webGL uniform location where to store the value
  87559. * @param array defines the array of int32 to store
  87560. */
  87561. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87562. /**
  87563. * Set the value of an uniform to an array of int32 (stored as vec3)
  87564. * @param uniform defines the webGL uniform location where to store the value
  87565. * @param array defines the array of int32 to store
  87566. */
  87567. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87568. /**
  87569. * Set the value of an uniform to an array of int32 (stored as vec4)
  87570. * @param uniform defines the webGL uniform location where to store the value
  87571. * @param array defines the array of int32 to store
  87572. */
  87573. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87574. /**
  87575. * Set the value of an uniform to an array of float32
  87576. * @param uniform defines the webGL uniform location where to store the value
  87577. * @param array defines the array of float32 to store
  87578. */
  87579. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87580. /**
  87581. * Set the value of an uniform to an array of float32 (stored as vec2)
  87582. * @param uniform defines the webGL uniform location where to store the value
  87583. * @param array defines the array of float32 to store
  87584. */
  87585. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87586. /**
  87587. * Set the value of an uniform to an array of float32 (stored as vec3)
  87588. * @param uniform defines the webGL uniform location where to store the value
  87589. * @param array defines the array of float32 to store
  87590. */
  87591. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87592. /**
  87593. * Set the value of an uniform to an array of float32 (stored as vec4)
  87594. * @param uniform defines the webGL uniform location where to store the value
  87595. * @param array defines the array of float32 to store
  87596. */
  87597. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87598. /**
  87599. * Set the value of an uniform to an array of number
  87600. * @param uniform defines the webGL uniform location where to store the value
  87601. * @param array defines the array of number to store
  87602. */
  87603. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87604. /**
  87605. * Set the value of an uniform to an array of number (stored as vec2)
  87606. * @param uniform defines the webGL uniform location where to store the value
  87607. * @param array defines the array of number to store
  87608. */
  87609. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87610. /**
  87611. * Set the value of an uniform to an array of number (stored as vec3)
  87612. * @param uniform defines the webGL uniform location where to store the value
  87613. * @param array defines the array of number to store
  87614. */
  87615. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87616. /**
  87617. * Set the value of an uniform to an array of number (stored as vec4)
  87618. * @param uniform defines the webGL uniform location where to store the value
  87619. * @param array defines the array of number to store
  87620. */
  87621. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87622. /**
  87623. * Set the value of an uniform to an array of float32 (stored as matrices)
  87624. * @param uniform defines the webGL uniform location where to store the value
  87625. * @param matrices defines the array of float32 to store
  87626. */
  87627. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87628. /**
  87629. * Set the value of an uniform to a matrix
  87630. * @param uniform defines the webGL uniform location where to store the value
  87631. * @param matrix defines the matrix to store
  87632. */
  87633. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87634. /**
  87635. * Set the value of an uniform to a matrix (3x3)
  87636. * @param uniform defines the webGL uniform location where to store the value
  87637. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87638. */
  87639. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87640. /**
  87641. * Set the value of an uniform to a matrix (2x2)
  87642. * @param uniform defines the webGL uniform location where to store the value
  87643. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87644. */
  87645. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87646. /**
  87647. * Set the value of an uniform to a number (int)
  87648. * @param uniform defines the webGL uniform location where to store the value
  87649. * @param value defines the int number to store
  87650. */
  87651. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87652. /**
  87653. * Set the value of an uniform to a number (float)
  87654. * @param uniform defines the webGL uniform location where to store the value
  87655. * @param value defines the float number to store
  87656. */
  87657. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87658. /**
  87659. * Set the value of an uniform to a vec2
  87660. * @param uniform defines the webGL uniform location where to store the value
  87661. * @param x defines the 1st component of the value
  87662. * @param y defines the 2nd component of the value
  87663. */
  87664. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87665. /**
  87666. * Set the value of an uniform to a vec3
  87667. * @param uniform defines the webGL uniform location where to store the value
  87668. * @param x defines the 1st component of the value
  87669. * @param y defines the 2nd component of the value
  87670. * @param z defines the 3rd component of the value
  87671. */
  87672. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87673. /**
  87674. * Set the value of an uniform to a boolean
  87675. * @param uniform defines the webGL uniform location where to store the value
  87676. * @param bool defines the boolean to store
  87677. */
  87678. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87679. /**
  87680. * Set the value of an uniform to a vec4
  87681. * @param uniform defines the webGL uniform location where to store the value
  87682. * @param x defines the 1st component of the value
  87683. * @param y defines the 2nd component of the value
  87684. * @param z defines the 3rd component of the value
  87685. * @param w defines the 4th component of the value
  87686. */
  87687. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87688. /**
  87689. * Set the value of an uniform to a Color3
  87690. * @param uniform defines the webGL uniform location where to store the value
  87691. * @param color3 defines the color to store
  87692. */
  87693. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87694. /**
  87695. * Set the value of an uniform to a Color3 and an alpha value
  87696. * @param uniform defines the webGL uniform location where to store the value
  87697. * @param color3 defines the color to store
  87698. * @param alpha defines the alpha component to store
  87699. */
  87700. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87701. /**
  87702. * Sets a Color4 on a uniform variable
  87703. * @param uniform defines the uniform location
  87704. * @param color4 defines the value to be set
  87705. */
  87706. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87707. /**
  87708. * Set various states to the webGL context
  87709. * @param culling defines backface culling state
  87710. * @param zOffset defines the value to apply to zOffset (0 by default)
  87711. * @param force defines if states must be applied even if cache is up to date
  87712. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87713. */
  87714. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  87715. /**
  87716. * Set the z offset to apply to current rendering
  87717. * @param value defines the offset to apply
  87718. */
  87719. setZOffset(value: number): void;
  87720. /**
  87721. * Gets the current value of the zOffset
  87722. * @returns the current zOffset state
  87723. */
  87724. getZOffset(): number;
  87725. /**
  87726. * Enable or disable depth buffering
  87727. * @param enable defines the state to set
  87728. */
  87729. setDepthBuffer(enable: boolean): void;
  87730. /**
  87731. * Gets a boolean indicating if depth writing is enabled
  87732. * @returns the current depth writing state
  87733. */
  87734. getDepthWrite(): boolean;
  87735. /**
  87736. * Enable or disable depth writing
  87737. * @param enable defines the state to set
  87738. */
  87739. setDepthWrite(enable: boolean): void;
  87740. /**
  87741. * Enable or disable color writing
  87742. * @param enable defines the state to set
  87743. */
  87744. setColorWrite(enable: boolean): void;
  87745. /**
  87746. * Gets a boolean indicating if color writing is enabled
  87747. * @returns the current color writing state
  87748. */
  87749. getColorWrite(): boolean;
  87750. /**
  87751. * Sets alpha constants used by some alpha blending modes
  87752. * @param r defines the red component
  87753. * @param g defines the green component
  87754. * @param b defines the blue component
  87755. * @param a defines the alpha component
  87756. */
  87757. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  87758. /**
  87759. * Sets the current alpha mode
  87760. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  87761. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  87762. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87763. */
  87764. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  87765. /**
  87766. * Gets the current alpha mode
  87767. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  87768. * @returns the current alpha mode
  87769. */
  87770. getAlphaMode(): number;
  87771. /**
  87772. * Clears the list of texture accessible through engine.
  87773. * This can help preventing texture load conflict due to name collision.
  87774. */
  87775. clearInternalTexturesCache(): void;
  87776. /**
  87777. * Force the entire cache to be cleared
  87778. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  87779. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  87780. */
  87781. wipeCaches(bruteForce?: boolean): void;
  87782. /**
  87783. * Set the compressed texture format to use, based on the formats you have, and the formats
  87784. * supported by the hardware / browser.
  87785. *
  87786. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  87787. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  87788. * to API arguments needed to compressed textures. This puts the burden on the container
  87789. * generator to house the arcane code for determining these for current & future formats.
  87790. *
  87791. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  87792. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  87793. *
  87794. * Note: The result of this call is not taken into account when a texture is base64.
  87795. *
  87796. * @param formatsAvailable defines the list of those format families you have created
  87797. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  87798. *
  87799. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  87800. * @returns The extension selected.
  87801. */
  87802. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  87803. private _getSamplingParameters;
  87804. private _partialLoadImg;
  87805. private _cascadeLoadImgs;
  87806. /** @hidden */
  87807. _createTexture(): WebGLTexture;
  87808. /**
  87809. * Usually called from Texture.ts.
  87810. * Passed information to create a WebGLTexture
  87811. * @param urlArg defines a value which contains one of the following:
  87812. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  87813. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  87814. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  87815. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  87816. * @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)
  87817. * @param scene needed for loading to the correct scene
  87818. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  87819. * @param onLoad optional callback to be called upon successful completion
  87820. * @param onError optional callback to be called upon failure
  87821. * @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
  87822. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  87823. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  87824. * @param forcedExtension defines the extension to use to pick the right loader
  87825. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  87826. * @returns a InternalTexture for assignment back into BABYLON.Texture
  87827. */
  87828. 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;
  87829. private _rescaleTexture;
  87830. /**
  87831. * Update a raw texture
  87832. * @param texture defines the texture to update
  87833. * @param data defines the data to store in the texture
  87834. * @param format defines the format of the data
  87835. * @param invertY defines if data must be stored with Y axis inverted
  87836. * @param compression defines the compression used (null by default)
  87837. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87838. */
  87839. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  87840. /**
  87841. * Creates a raw texture
  87842. * @param data defines the data to store in the texture
  87843. * @param width defines the width of the texture
  87844. * @param height defines the height of the texture
  87845. * @param format defines the format of the data
  87846. * @param generateMipMaps defines if the engine should generate the mip levels
  87847. * @param invertY defines if data must be stored with Y axis inverted
  87848. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87849. * @param compression defines the compression used (null by default)
  87850. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  87851. * @returns the raw texture inside an InternalTexture
  87852. */
  87853. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  87854. private _unpackFlipYCached;
  87855. /**
  87856. * In case you are sharing the context with other applications, it might
  87857. * be interested to not cache the unpack flip y state to ensure a consistent
  87858. * value would be set.
  87859. */
  87860. enableUnpackFlipYCached: boolean;
  87861. /** @hidden */
  87862. _unpackFlipY(value: boolean): void;
  87863. /** @hidden */
  87864. _getUnpackAlignement(): number;
  87865. /**
  87866. * Creates a dynamic texture
  87867. * @param width defines the width of the texture
  87868. * @param height defines the height of the texture
  87869. * @param generateMipMaps defines if the engine should generate the mip levels
  87870. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  87871. * @returns the dynamic texture inside an InternalTexture
  87872. */
  87873. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  87874. /**
  87875. * Update the sampling mode of a given texture
  87876. * @param samplingMode defines the required sampling mode
  87877. * @param texture defines the texture to update
  87878. */
  87879. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  87880. /**
  87881. * Update the content of a dynamic texture
  87882. * @param texture defines the texture to update
  87883. * @param canvas defines the canvas containing the source
  87884. * @param invertY defines if data must be stored with Y axis inverted
  87885. * @param premulAlpha defines if alpha is stored as premultiplied
  87886. * @param format defines the format of the data
  87887. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  87888. */
  87889. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  87890. /**
  87891. * Update a video texture
  87892. * @param texture defines the texture to update
  87893. * @param video defines the video element to use
  87894. * @param invertY defines if data must be stored with Y axis inverted
  87895. */
  87896. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  87897. /**
  87898. * Updates a depth texture Comparison Mode and Function.
  87899. * If the comparison Function is equal to 0, the mode will be set to none.
  87900. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  87901. * @param texture The texture to set the comparison function for
  87902. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  87903. */
  87904. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  87905. private _setupDepthStencilTexture;
  87906. /**
  87907. * Creates a depth stencil texture.
  87908. * This is only available in WebGL 2 or with the depth texture extension available.
  87909. * @param size The size of face edge in the texture.
  87910. * @param options The options defining the texture.
  87911. * @returns The texture
  87912. */
  87913. createDepthStencilTexture(size: number | {
  87914. width: number;
  87915. height: number;
  87916. }, options: DepthTextureCreationOptions): InternalTexture;
  87917. /**
  87918. * Creates a depth stencil texture.
  87919. * This is only available in WebGL 2 or with the depth texture extension available.
  87920. * @param size The size of face edge in the texture.
  87921. * @param options The options defining the texture.
  87922. * @returns The texture
  87923. */
  87924. private _createDepthStencilTexture;
  87925. /**
  87926. * Creates a depth stencil cube texture.
  87927. * This is only available in WebGL 2.
  87928. * @param size The size of face edge in the cube texture.
  87929. * @param options The options defining the cube texture.
  87930. * @returns The cube texture
  87931. */
  87932. private _createDepthStencilCubeTexture;
  87933. /**
  87934. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  87935. * @param renderTarget The render target to set the frame buffer for
  87936. */
  87937. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  87938. /**
  87939. * Creates a new render target texture
  87940. * @param size defines the size of the texture
  87941. * @param options defines the options used to create the texture
  87942. * @returns a new render target texture stored in an InternalTexture
  87943. */
  87944. createRenderTargetTexture(size: number | {
  87945. width: number;
  87946. height: number;
  87947. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  87948. /**
  87949. * Create a multi render target texture
  87950. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  87951. * @param size defines the size of the texture
  87952. * @param options defines the creation options
  87953. * @returns the cube texture as an InternalTexture
  87954. */
  87955. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  87956. private _setupFramebufferDepthAttachments;
  87957. /**
  87958. * Updates the sample count of a render target texture
  87959. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87960. * @param texture defines the texture to update
  87961. * @param samples defines the sample count to set
  87962. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87963. */
  87964. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  87965. /**
  87966. * Update the sample count for a given multiple render target texture
  87967. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  87968. * @param textures defines the textures to update
  87969. * @param samples defines the sample count to set
  87970. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  87971. */
  87972. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  87973. /** @hidden */
  87974. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87975. /** @hidden */
  87976. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87977. /** @hidden */
  87978. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  87979. /** @hidden */
  87980. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  87981. /**
  87982. * Creates a new render target cube texture
  87983. * @param size defines the size of the texture
  87984. * @param options defines the options used to create the texture
  87985. * @returns a new render target cube texture stored in an InternalTexture
  87986. */
  87987. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  87988. /**
  87989. * Creates a cube texture
  87990. * @param rootUrl defines the url where the files to load is located
  87991. * @param scene defines the current scene
  87992. * @param files defines the list of files to load (1 per face)
  87993. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  87994. * @param onLoad defines an optional callback raised when the texture is loaded
  87995. * @param onError defines an optional callback raised if there is an issue to load the texture
  87996. * @param format defines the format of the data
  87997. * @param forcedExtension defines the extension to use to pick the right loader
  87998. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  87999. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88000. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88001. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88002. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  88003. * @returns the cube texture as an InternalTexture
  88004. */
  88005. 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;
  88006. /**
  88007. * @hidden
  88008. */
  88009. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88010. /**
  88011. * Update a raw cube texture
  88012. * @param texture defines the texture to udpdate
  88013. * @param data defines the data to store
  88014. * @param format defines the data format
  88015. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  88016. * @param invertY defines if data must be stored with Y axis inverted
  88017. * @param compression defines the compression used (null by default)
  88018. * @param level defines which level of the texture to update
  88019. */
  88020. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  88021. /**
  88022. * Creates a new raw cube texture
  88023. * @param data defines the array of data to use to create each face
  88024. * @param size defines the size of the textures
  88025. * @param format defines the format of the data
  88026. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88027. * @param generateMipMaps defines if the engine should generate the mip levels
  88028. * @param invertY defines if data must be stored with Y axis inverted
  88029. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88030. * @param compression defines the compression used (null by default)
  88031. * @returns the cube texture as an InternalTexture
  88032. */
  88033. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  88034. /**
  88035. * Creates a new raw cube texture from a specified url
  88036. * @param url defines the url where the data is located
  88037. * @param scene defines the current scene
  88038. * @param size defines the size of the textures
  88039. * @param format defines the format of the data
  88040. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  88041. * @param noMipmap defines if the engine should avoid generating the mip levels
  88042. * @param callback defines a callback used to extract texture data from loaded data
  88043. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  88044. * @param onLoad defines a callback called when texture is loaded
  88045. * @param onError defines a callback called if there is an error
  88046. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88047. * @param invertY defines if data must be stored with Y axis inverted
  88048. * @returns the cube texture as an InternalTexture
  88049. */
  88050. 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;
  88051. /**
  88052. * Update a raw 3D texture
  88053. * @param texture defines the texture to update
  88054. * @param data defines the data to store
  88055. * @param format defines the data format
  88056. * @param invertY defines if data must be stored with Y axis inverted
  88057. * @param compression defines the used compression (can be null)
  88058. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  88059. */
  88060. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  88061. /**
  88062. * Creates a new raw 3D texture
  88063. * @param data defines the data used to create the texture
  88064. * @param width defines the width of the texture
  88065. * @param height defines the height of the texture
  88066. * @param depth defines the depth of the texture
  88067. * @param format defines the format of the texture
  88068. * @param generateMipMaps defines if the engine must generate mip levels
  88069. * @param invertY defines if data must be stored with Y axis inverted
  88070. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  88071. * @param compression defines the compressed used (can be null)
  88072. * @param textureType defines the compressed used (can be null)
  88073. * @returns a new raw 3D texture (stored in an InternalTexture)
  88074. */
  88075. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  88076. private _prepareWebGLTextureContinuation;
  88077. private _prepareWebGLTexture;
  88078. private _convertRGBtoRGBATextureData;
  88079. /** @hidden */
  88080. _releaseFramebufferObjects(texture: InternalTexture): void;
  88081. /** @hidden */
  88082. _releaseTexture(texture: InternalTexture): void;
  88083. private setProgram;
  88084. private _boundUniforms;
  88085. /**
  88086. * Binds an effect to the webGL context
  88087. * @param effect defines the effect to bind
  88088. */
  88089. bindSamplers(effect: Effect): void;
  88090. private _activateCurrentTexture;
  88091. /** @hidden */
  88092. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88093. /** @hidden */
  88094. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88095. /**
  88096. * Sets a texture to the webGL context from a postprocess
  88097. * @param channel defines the channel to use
  88098. * @param postProcess defines the source postprocess
  88099. */
  88100. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88101. /**
  88102. * Binds the output of the passed in post process to the texture channel specified
  88103. * @param channel The channel the texture should be bound to
  88104. * @param postProcess The post process which's output should be bound
  88105. */
  88106. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88107. /**
  88108. * Unbind all textures from the webGL context
  88109. */
  88110. unbindAllTextures(): void;
  88111. /**
  88112. * Sets a texture to the according uniform.
  88113. * @param channel The texture channel
  88114. * @param uniform The uniform to set
  88115. * @param texture The texture to apply
  88116. */
  88117. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88118. /**
  88119. * Sets a depth stencil texture from a render target to the according uniform.
  88120. * @param channel The texture channel
  88121. * @param uniform The uniform to set
  88122. * @param texture The render target texture containing the depth stencil texture to apply
  88123. */
  88124. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88125. private _bindSamplerUniformToChannel;
  88126. private _getTextureWrapMode;
  88127. private _setTexture;
  88128. /**
  88129. * Sets an array of texture to the webGL context
  88130. * @param channel defines the channel where the texture array must be set
  88131. * @param uniform defines the associated uniform location
  88132. * @param textures defines the array of textures to bind
  88133. */
  88134. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88135. /** @hidden */
  88136. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88137. private _setTextureParameterFloat;
  88138. private _setTextureParameterInteger;
  88139. /**
  88140. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88141. * @param x defines the x coordinate of the rectangle where pixels must be read
  88142. * @param y defines the y coordinate of the rectangle where pixels must be read
  88143. * @param width defines the width of the rectangle where pixels must be read
  88144. * @param height defines the height of the rectangle where pixels must be read
  88145. * @returns a Uint8Array containing RGBA colors
  88146. */
  88147. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88148. /**
  88149. * Add an externaly attached data from its key.
  88150. * This method call will fail and return false, if such key already exists.
  88151. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88152. * @param key the unique key that identifies the data
  88153. * @param data the data object to associate to the key for this Engine instance
  88154. * @return true if no such key were already present and the data was added successfully, false otherwise
  88155. */
  88156. addExternalData<T>(key: string, data: T): boolean;
  88157. /**
  88158. * Get an externaly attached data from its key
  88159. * @param key the unique key that identifies the data
  88160. * @return the associated data, if present (can be null), or undefined if not present
  88161. */
  88162. getExternalData<T>(key: string): T;
  88163. /**
  88164. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88165. * @param key the unique key that identifies the data
  88166. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88167. * @return the associated data, can be null if the factory returned null.
  88168. */
  88169. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88170. /**
  88171. * Remove an externaly attached data from the Engine instance
  88172. * @param key the unique key that identifies the data
  88173. * @return true if the data was successfully removed, false if it doesn't exist
  88174. */
  88175. removeExternalData(key: string): boolean;
  88176. /**
  88177. * Unbind all vertex attributes from the webGL context
  88178. */
  88179. unbindAllAttributes(): void;
  88180. /**
  88181. * 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
  88182. */
  88183. releaseEffects(): void;
  88184. /**
  88185. * Dispose and release all associated resources
  88186. */
  88187. dispose(): void;
  88188. /**
  88189. * Display the loading screen
  88190. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88191. */
  88192. displayLoadingUI(): void;
  88193. /**
  88194. * Hide the loading screen
  88195. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88196. */
  88197. hideLoadingUI(): void;
  88198. /**
  88199. * Gets the current loading screen object
  88200. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88201. */
  88202. /**
  88203. * Sets the current loading screen object
  88204. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88205. */
  88206. loadingScreen: ILoadingScreen;
  88207. /**
  88208. * Sets the current loading screen text
  88209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88210. */
  88211. loadingUIText: string;
  88212. /**
  88213. * Sets the current loading screen background color
  88214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88215. */
  88216. loadingUIBackgroundColor: string;
  88217. /**
  88218. * Attach a new callback raised when context lost event is fired
  88219. * @param callback defines the callback to call
  88220. */
  88221. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88222. /**
  88223. * Attach a new callback raised when context restored event is fired
  88224. * @param callback defines the callback to call
  88225. */
  88226. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88227. /**
  88228. * Gets the source code of the vertex shader associated with a specific webGL program
  88229. * @param program defines the program to use
  88230. * @returns a string containing the source code of the vertex shader associated with the program
  88231. */
  88232. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88233. /**
  88234. * Gets the source code of the fragment shader associated with a specific webGL program
  88235. * @param program defines the program to use
  88236. * @returns a string containing the source code of the fragment shader associated with the program
  88237. */
  88238. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88239. /**
  88240. * Get the current error code of the webGL context
  88241. * @returns the error code
  88242. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88243. */
  88244. getError(): number;
  88245. /**
  88246. * Gets the current framerate
  88247. * @returns a number representing the framerate
  88248. */
  88249. getFps(): number;
  88250. /**
  88251. * Gets the time spent between current and previous frame
  88252. * @returns a number representing the delta time in ms
  88253. */
  88254. getDeltaTime(): number;
  88255. private _measureFps;
  88256. /** @hidden */
  88257. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88258. private _canRenderToFloatFramebuffer;
  88259. private _canRenderToHalfFloatFramebuffer;
  88260. private _canRenderToFramebuffer;
  88261. /** @hidden */
  88262. _getWebGLTextureType(type: number): number;
  88263. private _getInternalFormat;
  88264. /** @hidden */
  88265. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88266. /** @hidden */
  88267. _getRGBAMultiSampleBufferFormat(type: number): number;
  88268. /** @hidden */
  88269. _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;
  88270. /** @hidden */
  88271. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88272. private _partialLoadFile;
  88273. private _cascadeLoadFiles;
  88274. /**
  88275. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88276. * @returns true if the engine can be created
  88277. * @ignorenaming
  88278. */
  88279. static isSupported(): boolean;
  88280. }
  88281. }
  88282. declare module BABYLON {
  88283. /**
  88284. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88285. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88286. */
  88287. export class EffectFallbacks {
  88288. private _defines;
  88289. private _currentRank;
  88290. private _maxRank;
  88291. private _mesh;
  88292. /**
  88293. * Removes the fallback from the bound mesh.
  88294. */
  88295. unBindMesh(): void;
  88296. /**
  88297. * Adds a fallback on the specified property.
  88298. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88299. * @param define The name of the define in the shader
  88300. */
  88301. addFallback(rank: number, define: string): void;
  88302. /**
  88303. * Sets the mesh to use CPU skinning when needing to fallback.
  88304. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88305. * @param mesh The mesh to use the fallbacks.
  88306. */
  88307. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88308. /**
  88309. * Checks to see if more fallbacks are still availible.
  88310. */
  88311. readonly isMoreFallbacks: boolean;
  88312. /**
  88313. * Removes the defines that shoould be removed when falling back.
  88314. * @param currentDefines defines the current define statements for the shader.
  88315. * @param effect defines the current effect we try to compile
  88316. * @returns The resulting defines with defines of the current rank removed.
  88317. */
  88318. reduce(currentDefines: string, effect: Effect): string;
  88319. }
  88320. /**
  88321. * Options to be used when creating an effect.
  88322. */
  88323. export class EffectCreationOptions {
  88324. /**
  88325. * Atrributes that will be used in the shader.
  88326. */
  88327. attributes: string[];
  88328. /**
  88329. * Uniform varible names that will be set in the shader.
  88330. */
  88331. uniformsNames: string[];
  88332. /**
  88333. * Uniform buffer varible names that will be set in the shader.
  88334. */
  88335. uniformBuffersNames: string[];
  88336. /**
  88337. * Sampler texture variable names that will be set in the shader.
  88338. */
  88339. samplers: string[];
  88340. /**
  88341. * Define statements that will be set in the shader.
  88342. */
  88343. defines: any;
  88344. /**
  88345. * Possible fallbacks for this effect to improve performance when needed.
  88346. */
  88347. fallbacks: Nullable<EffectFallbacks>;
  88348. /**
  88349. * Callback that will be called when the shader is compiled.
  88350. */
  88351. onCompiled: Nullable<(effect: Effect) => void>;
  88352. /**
  88353. * Callback that will be called if an error occurs during shader compilation.
  88354. */
  88355. onError: Nullable<(effect: Effect, errors: string) => void>;
  88356. /**
  88357. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88358. */
  88359. indexParameters: any;
  88360. /**
  88361. * Max number of lights that can be used in the shader.
  88362. */
  88363. maxSimultaneousLights: number;
  88364. /**
  88365. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88366. */
  88367. transformFeedbackVaryings: Nullable<string[]>;
  88368. }
  88369. /**
  88370. * Effect containing vertex and fragment shader that can be executed on an object.
  88371. */
  88372. export class Effect implements IDisposable {
  88373. /**
  88374. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88375. */
  88376. static ShadersRepository: string;
  88377. /**
  88378. * Name of the effect.
  88379. */
  88380. name: any;
  88381. /**
  88382. * String container all the define statements that should be set on the shader.
  88383. */
  88384. defines: string;
  88385. /**
  88386. * Callback that will be called when the shader is compiled.
  88387. */
  88388. onCompiled: Nullable<(effect: Effect) => void>;
  88389. /**
  88390. * Callback that will be called if an error occurs during shader compilation.
  88391. */
  88392. onError: Nullable<(effect: Effect, errors: string) => void>;
  88393. /**
  88394. * Callback that will be called when effect is bound.
  88395. */
  88396. onBind: Nullable<(effect: Effect) => void>;
  88397. /**
  88398. * Unique ID of the effect.
  88399. */
  88400. uniqueId: number;
  88401. /**
  88402. * Observable that will be called when the shader is compiled.
  88403. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88404. */
  88405. onCompileObservable: Observable<Effect>;
  88406. /**
  88407. * Observable that will be called if an error occurs during shader compilation.
  88408. */
  88409. onErrorObservable: Observable<Effect>;
  88410. /** @hidden */
  88411. _onBindObservable: Nullable<Observable<Effect>>;
  88412. /**
  88413. * Observable that will be called when effect is bound.
  88414. */
  88415. readonly onBindObservable: Observable<Effect>;
  88416. /** @hidden */
  88417. _bonesComputationForcedToCPU: boolean;
  88418. private static _uniqueIdSeed;
  88419. private _engine;
  88420. private _uniformBuffersNames;
  88421. private _uniformsNames;
  88422. private _samplerList;
  88423. private _samplers;
  88424. private _isReady;
  88425. private _compilationError;
  88426. private _attributesNames;
  88427. private _attributes;
  88428. private _uniforms;
  88429. /**
  88430. * Key for the effect.
  88431. * @hidden
  88432. */
  88433. _key: string;
  88434. private _indexParameters;
  88435. private _fallbacks;
  88436. private _vertexSourceCode;
  88437. private _fragmentSourceCode;
  88438. private _vertexSourceCodeOverride;
  88439. private _fragmentSourceCodeOverride;
  88440. private _transformFeedbackVaryings;
  88441. /**
  88442. * Compiled shader to webGL program.
  88443. * @hidden
  88444. */
  88445. _program: WebGLProgram;
  88446. private _valueCache;
  88447. private static _baseCache;
  88448. /**
  88449. * Instantiates an effect.
  88450. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88451. * @param baseName Name of the effect.
  88452. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88453. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88454. * @param samplers List of sampler variables that will be passed to the shader.
  88455. * @param engine Engine to be used to render the effect
  88456. * @param defines Define statements to be added to the shader.
  88457. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88458. * @param onCompiled Callback that will be called when the shader is compiled.
  88459. * @param onError Callback that will be called if an error occurs during shader compilation.
  88460. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88461. */
  88462. 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);
  88463. /**
  88464. * Unique key for this effect
  88465. */
  88466. readonly key: string;
  88467. /**
  88468. * If the effect has been compiled and prepared.
  88469. * @returns if the effect is compiled and prepared.
  88470. */
  88471. isReady(): boolean;
  88472. /**
  88473. * The engine the effect was initialized with.
  88474. * @returns the engine.
  88475. */
  88476. getEngine(): Engine;
  88477. /**
  88478. * The compiled webGL program for the effect
  88479. * @returns the webGL program.
  88480. */
  88481. getProgram(): WebGLProgram;
  88482. /**
  88483. * The set of names of attribute variables for the shader.
  88484. * @returns An array of attribute names.
  88485. */
  88486. getAttributesNames(): string[];
  88487. /**
  88488. * Returns the attribute at the given index.
  88489. * @param index The index of the attribute.
  88490. * @returns The location of the attribute.
  88491. */
  88492. getAttributeLocation(index: number): number;
  88493. /**
  88494. * Returns the attribute based on the name of the variable.
  88495. * @param name of the attribute to look up.
  88496. * @returns the attribute location.
  88497. */
  88498. getAttributeLocationByName(name: string): number;
  88499. /**
  88500. * The number of attributes.
  88501. * @returns the numnber of attributes.
  88502. */
  88503. getAttributesCount(): number;
  88504. /**
  88505. * Gets the index of a uniform variable.
  88506. * @param uniformName of the uniform to look up.
  88507. * @returns the index.
  88508. */
  88509. getUniformIndex(uniformName: string): number;
  88510. /**
  88511. * Returns the attribute based on the name of the variable.
  88512. * @param uniformName of the uniform to look up.
  88513. * @returns the location of the uniform.
  88514. */
  88515. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88516. /**
  88517. * Returns an array of sampler variable names
  88518. * @returns The array of sampler variable neames.
  88519. */
  88520. getSamplers(): string[];
  88521. /**
  88522. * The error from the last compilation.
  88523. * @returns the error string.
  88524. */
  88525. getCompilationError(): string;
  88526. /**
  88527. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88528. * @param func The callback to be used.
  88529. */
  88530. executeWhenCompiled(func: (effect: Effect) => void): void;
  88531. private _checkIsReady;
  88532. /** @hidden */
  88533. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88534. /** @hidden */
  88535. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88536. /** @hidden */
  88537. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88538. private _processShaderConversion;
  88539. private _processIncludes;
  88540. private _processPrecision;
  88541. /**
  88542. * Recompiles the webGL program
  88543. * @param vertexSourceCode The source code for the vertex shader.
  88544. * @param fragmentSourceCode The source code for the fragment shader.
  88545. * @param onCompiled Callback called when completed.
  88546. * @param onError Callback called on error.
  88547. * @hidden
  88548. */
  88549. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88550. /**
  88551. * Gets the uniform locations of the the specified variable names
  88552. * @param names THe names of the variables to lookup.
  88553. * @returns Array of locations in the same order as variable names.
  88554. */
  88555. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88556. /**
  88557. * Prepares the effect
  88558. * @hidden
  88559. */
  88560. _prepareEffect(): void;
  88561. /**
  88562. * Checks if the effect is supported. (Must be called after compilation)
  88563. */
  88564. readonly isSupported: boolean;
  88565. /**
  88566. * Binds a texture to the engine to be used as output of the shader.
  88567. * @param channel Name of the output variable.
  88568. * @param texture Texture to bind.
  88569. * @hidden
  88570. */
  88571. _bindTexture(channel: string, texture: InternalTexture): void;
  88572. /**
  88573. * Sets a texture on the engine to be used in the shader.
  88574. * @param channel Name of the sampler variable.
  88575. * @param texture Texture to set.
  88576. */
  88577. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88578. /**
  88579. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88580. * @param channel Name of the sampler variable.
  88581. * @param texture Texture to set.
  88582. */
  88583. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88584. /**
  88585. * Sets an array of textures on the engine to be used in the shader.
  88586. * @param channel Name of the variable.
  88587. * @param textures Textures to set.
  88588. */
  88589. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88590. /**
  88591. * 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)
  88592. * @param channel Name of the sampler variable.
  88593. * @param postProcess Post process to get the input texture from.
  88594. */
  88595. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88596. /**
  88597. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88598. * 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)
  88599. * @param channel Name of the sampler variable.
  88600. * @param postProcess Post process to get the output texture from.
  88601. */
  88602. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88603. /** @hidden */
  88604. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88605. /** @hidden */
  88606. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88607. /** @hidden */
  88608. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88609. /** @hidden */
  88610. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88611. /**
  88612. * Binds a buffer to a uniform.
  88613. * @param buffer Buffer to bind.
  88614. * @param name Name of the uniform variable to bind to.
  88615. */
  88616. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88617. /**
  88618. * Binds block to a uniform.
  88619. * @param blockName Name of the block to bind.
  88620. * @param index Index to bind.
  88621. */
  88622. bindUniformBlock(blockName: string, index: number): void;
  88623. /**
  88624. * Sets an interger value on a uniform variable.
  88625. * @param uniformName Name of the variable.
  88626. * @param value Value to be set.
  88627. * @returns this effect.
  88628. */
  88629. setInt(uniformName: string, value: number): Effect;
  88630. /**
  88631. * Sets an int array on a uniform variable.
  88632. * @param uniformName Name of the variable.
  88633. * @param array array to be set.
  88634. * @returns this effect.
  88635. */
  88636. setIntArray(uniformName: string, array: Int32Array): Effect;
  88637. /**
  88638. * 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)
  88639. * @param uniformName Name of the variable.
  88640. * @param array array to be set.
  88641. * @returns this effect.
  88642. */
  88643. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88644. /**
  88645. * 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)
  88646. * @param uniformName Name of the variable.
  88647. * @param array array to be set.
  88648. * @returns this effect.
  88649. */
  88650. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88651. /**
  88652. * 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)
  88653. * @param uniformName Name of the variable.
  88654. * @param array array to be set.
  88655. * @returns this effect.
  88656. */
  88657. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88658. /**
  88659. * Sets an float array on a uniform variable.
  88660. * @param uniformName Name of the variable.
  88661. * @param array array to be set.
  88662. * @returns this effect.
  88663. */
  88664. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88665. /**
  88666. * 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)
  88667. * @param uniformName Name of the variable.
  88668. * @param array array to be set.
  88669. * @returns this effect.
  88670. */
  88671. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88672. /**
  88673. * 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)
  88674. * @param uniformName Name of the variable.
  88675. * @param array array to be set.
  88676. * @returns this effect.
  88677. */
  88678. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88679. /**
  88680. * 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)
  88681. * @param uniformName Name of the variable.
  88682. * @param array array to be set.
  88683. * @returns this effect.
  88684. */
  88685. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88686. /**
  88687. * Sets an array on a uniform variable.
  88688. * @param uniformName Name of the variable.
  88689. * @param array array to be set.
  88690. * @returns this effect.
  88691. */
  88692. setArray(uniformName: string, array: number[]): Effect;
  88693. /**
  88694. * 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)
  88695. * @param uniformName Name of the variable.
  88696. * @param array array to be set.
  88697. * @returns this effect.
  88698. */
  88699. setArray2(uniformName: string, array: number[]): Effect;
  88700. /**
  88701. * 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)
  88702. * @param uniformName Name of the variable.
  88703. * @param array array to be set.
  88704. * @returns this effect.
  88705. */
  88706. setArray3(uniformName: string, array: number[]): Effect;
  88707. /**
  88708. * 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)
  88709. * @param uniformName Name of the variable.
  88710. * @param array array to be set.
  88711. * @returns this effect.
  88712. */
  88713. setArray4(uniformName: string, array: number[]): Effect;
  88714. /**
  88715. * Sets matrices on a uniform variable.
  88716. * @param uniformName Name of the variable.
  88717. * @param matrices matrices to be set.
  88718. * @returns this effect.
  88719. */
  88720. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88721. /**
  88722. * Sets matrix on a uniform variable.
  88723. * @param uniformName Name of the variable.
  88724. * @param matrix matrix to be set.
  88725. * @returns this effect.
  88726. */
  88727. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88728. /**
  88729. * 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)
  88730. * @param uniformName Name of the variable.
  88731. * @param matrix matrix to be set.
  88732. * @returns this effect.
  88733. */
  88734. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88735. /**
  88736. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88737. * @param uniformName Name of the variable.
  88738. * @param matrix matrix to be set.
  88739. * @returns this effect.
  88740. */
  88741. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88742. /**
  88743. * Sets a float on a uniform variable.
  88744. * @param uniformName Name of the variable.
  88745. * @param value value to be set.
  88746. * @returns this effect.
  88747. */
  88748. setFloat(uniformName: string, value: number): Effect;
  88749. /**
  88750. * Sets a boolean on a uniform variable.
  88751. * @param uniformName Name of the variable.
  88752. * @param bool value to be set.
  88753. * @returns this effect.
  88754. */
  88755. setBool(uniformName: string, bool: boolean): Effect;
  88756. /**
  88757. * Sets a Vector2 on a uniform variable.
  88758. * @param uniformName Name of the variable.
  88759. * @param vector2 vector2 to be set.
  88760. * @returns this effect.
  88761. */
  88762. setVector2(uniformName: string, vector2: Vector2): Effect;
  88763. /**
  88764. * Sets a float2 on a uniform variable.
  88765. * @param uniformName Name of the variable.
  88766. * @param x First float in float2.
  88767. * @param y Second float in float2.
  88768. * @returns this effect.
  88769. */
  88770. setFloat2(uniformName: string, x: number, y: number): Effect;
  88771. /**
  88772. * Sets a Vector3 on a uniform variable.
  88773. * @param uniformName Name of the variable.
  88774. * @param vector3 Value to be set.
  88775. * @returns this effect.
  88776. */
  88777. setVector3(uniformName: string, vector3: Vector3): Effect;
  88778. /**
  88779. * Sets a float3 on a uniform variable.
  88780. * @param uniformName Name of the variable.
  88781. * @param x First float in float3.
  88782. * @param y Second float in float3.
  88783. * @param z Third float in float3.
  88784. * @returns this effect.
  88785. */
  88786. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88787. /**
  88788. * Sets a Vector4 on a uniform variable.
  88789. * @param uniformName Name of the variable.
  88790. * @param vector4 Value to be set.
  88791. * @returns this effect.
  88792. */
  88793. setVector4(uniformName: string, vector4: Vector4): Effect;
  88794. /**
  88795. * Sets a float4 on a uniform variable.
  88796. * @param uniformName Name of the variable.
  88797. * @param x First float in float4.
  88798. * @param y Second float in float4.
  88799. * @param z Third float in float4.
  88800. * @param w Fourth float in float4.
  88801. * @returns this effect.
  88802. */
  88803. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  88804. /**
  88805. * Sets a Color3 on a uniform variable.
  88806. * @param uniformName Name of the variable.
  88807. * @param color3 Value to be set.
  88808. * @returns this effect.
  88809. */
  88810. setColor3(uniformName: string, color3: Color3): Effect;
  88811. /**
  88812. * Sets a Color4 on a uniform variable.
  88813. * @param uniformName Name of the variable.
  88814. * @param color3 Value to be set.
  88815. * @param alpha Alpha value to be set.
  88816. * @returns this effect.
  88817. */
  88818. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  88819. /**
  88820. * Sets a Color4 on a uniform variable
  88821. * @param uniformName defines the name of the variable
  88822. * @param color4 defines the value to be set
  88823. * @returns this effect.
  88824. */
  88825. setDirectColor4(uniformName: string, color4: Color4): Effect;
  88826. /** Release all associated resources */
  88827. dispose(): void;
  88828. /**
  88829. * This function will add a new shader to the shader store
  88830. * @param name the name of the shader
  88831. * @param pixelShader optional pixel shader content
  88832. * @param vertexShader optional vertex shader content
  88833. */
  88834. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  88835. /**
  88836. * Store of each shader (The can be looked up using effect.key)
  88837. */
  88838. static ShadersStore: {
  88839. [key: string]: string;
  88840. };
  88841. /**
  88842. * Store of each included file for a shader (The can be looked up using effect.key)
  88843. */
  88844. static IncludesShadersStore: {
  88845. [key: string]: string;
  88846. };
  88847. /**
  88848. * Resets the cache of effects.
  88849. */
  88850. static ResetCache(): void;
  88851. }
  88852. }
  88853. declare module BABYLON {
  88854. /**
  88855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88857. * 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;
  88858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88859. */
  88860. export class ColorCurves {
  88861. private _dirty;
  88862. private _tempColor;
  88863. private _globalCurve;
  88864. private _highlightsCurve;
  88865. private _midtonesCurve;
  88866. private _shadowsCurve;
  88867. private _positiveCurve;
  88868. private _negativeCurve;
  88869. private _globalHue;
  88870. private _globalDensity;
  88871. private _globalSaturation;
  88872. private _globalExposure;
  88873. /**
  88874. * Gets the global Hue value.
  88875. * 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).
  88876. */
  88877. /**
  88878. * Sets the global Hue value.
  88879. * 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).
  88880. */
  88881. globalHue: number;
  88882. /**
  88883. * Gets the global Density value.
  88884. * 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.
  88885. * Values less than zero provide a filter of opposite hue.
  88886. */
  88887. /**
  88888. * Sets the global Density value.
  88889. * 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.
  88890. * Values less than zero provide a filter of opposite hue.
  88891. */
  88892. globalDensity: number;
  88893. /**
  88894. * Gets the global Saturation value.
  88895. * 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.
  88896. */
  88897. /**
  88898. * Sets the global Saturation value.
  88899. * 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.
  88900. */
  88901. globalSaturation: number;
  88902. /**
  88903. * Gets the global Exposure value.
  88904. * 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.
  88905. */
  88906. /**
  88907. * Sets the global Exposure value.
  88908. * 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.
  88909. */
  88910. globalExposure: number;
  88911. private _highlightsHue;
  88912. private _highlightsDensity;
  88913. private _highlightsSaturation;
  88914. private _highlightsExposure;
  88915. /**
  88916. * Gets the highlights Hue value.
  88917. * 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).
  88918. */
  88919. /**
  88920. * Sets the highlights Hue value.
  88921. * 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).
  88922. */
  88923. highlightsHue: number;
  88924. /**
  88925. * Gets the highlights Density value.
  88926. * 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.
  88927. * Values less than zero provide a filter of opposite hue.
  88928. */
  88929. /**
  88930. * Sets the highlights Density value.
  88931. * 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.
  88932. * Values less than zero provide a filter of opposite hue.
  88933. */
  88934. highlightsDensity: number;
  88935. /**
  88936. * Gets the highlights Saturation value.
  88937. * 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.
  88938. */
  88939. /**
  88940. * Sets the highlights Saturation value.
  88941. * 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.
  88942. */
  88943. highlightsSaturation: number;
  88944. /**
  88945. * Gets the highlights Exposure value.
  88946. * 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.
  88947. */
  88948. /**
  88949. * Sets the highlights Exposure value.
  88950. * 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.
  88951. */
  88952. highlightsExposure: number;
  88953. private _midtonesHue;
  88954. private _midtonesDensity;
  88955. private _midtonesSaturation;
  88956. private _midtonesExposure;
  88957. /**
  88958. * Gets the midtones Hue value.
  88959. * 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).
  88960. */
  88961. /**
  88962. * Sets the midtones Hue value.
  88963. * 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).
  88964. */
  88965. midtonesHue: number;
  88966. /**
  88967. * Gets the midtones Density value.
  88968. * 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.
  88969. * Values less than zero provide a filter of opposite hue.
  88970. */
  88971. /**
  88972. * Sets the midtones Density value.
  88973. * 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.
  88974. * Values less than zero provide a filter of opposite hue.
  88975. */
  88976. midtonesDensity: number;
  88977. /**
  88978. * Gets the midtones Saturation value.
  88979. * 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.
  88980. */
  88981. /**
  88982. * Sets the midtones Saturation value.
  88983. * 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.
  88984. */
  88985. midtonesSaturation: number;
  88986. /**
  88987. * Gets the midtones Exposure value.
  88988. * 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.
  88989. */
  88990. /**
  88991. * Sets the midtones Exposure value.
  88992. * 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.
  88993. */
  88994. midtonesExposure: number;
  88995. private _shadowsHue;
  88996. private _shadowsDensity;
  88997. private _shadowsSaturation;
  88998. private _shadowsExposure;
  88999. /**
  89000. * Gets the shadows Hue value.
  89001. * 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).
  89002. */
  89003. /**
  89004. * Sets the shadows Hue value.
  89005. * 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).
  89006. */
  89007. shadowsHue: number;
  89008. /**
  89009. * Gets the shadows Density value.
  89010. * 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.
  89011. * Values less than zero provide a filter of opposite hue.
  89012. */
  89013. /**
  89014. * Sets the shadows Density value.
  89015. * 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.
  89016. * Values less than zero provide a filter of opposite hue.
  89017. */
  89018. shadowsDensity: number;
  89019. /**
  89020. * Gets the shadows Saturation value.
  89021. * 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.
  89022. */
  89023. /**
  89024. * Sets the shadows Saturation value.
  89025. * 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.
  89026. */
  89027. shadowsSaturation: number;
  89028. /**
  89029. * Gets the shadows Exposure value.
  89030. * 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.
  89031. */
  89032. /**
  89033. * Sets the shadows Exposure value.
  89034. * 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.
  89035. */
  89036. shadowsExposure: number;
  89037. /**
  89038. * Returns the class name
  89039. * @returns The class name
  89040. */
  89041. getClassName(): string;
  89042. /**
  89043. * Binds the color curves to the shader.
  89044. * @param colorCurves The color curve to bind
  89045. * @param effect The effect to bind to
  89046. * @param positiveUniform The positive uniform shader parameter
  89047. * @param neutralUniform The neutral uniform shader parameter
  89048. * @param negativeUniform The negative uniform shader parameter
  89049. */
  89050. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89051. /**
  89052. * Prepare the list of uniforms associated with the ColorCurves effects.
  89053. * @param uniformsList The list of uniforms used in the effect
  89054. */
  89055. static PrepareUniforms(uniformsList: string[]): void;
  89056. /**
  89057. * Returns color grading data based on a hue, density, saturation and exposure value.
  89058. * @param filterHue The hue of the color filter.
  89059. * @param filterDensity The density of the color filter.
  89060. * @param saturation The saturation.
  89061. * @param exposure The exposure.
  89062. * @param result The result data container.
  89063. */
  89064. private getColorGradingDataToRef;
  89065. /**
  89066. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89067. * @param value The input slider value in range [-100,100].
  89068. * @returns Adjusted value.
  89069. */
  89070. private static applyColorGradingSliderNonlinear;
  89071. /**
  89072. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89073. * @param hue The hue (H) input.
  89074. * @param saturation The saturation (S) input.
  89075. * @param brightness The brightness (B) input.
  89076. * @result An RGBA color represented as Vector4.
  89077. */
  89078. private static fromHSBToRef;
  89079. /**
  89080. * Returns a value clamped between min and max
  89081. * @param value The value to clamp
  89082. * @param min The minimum of value
  89083. * @param max The maximum of value
  89084. * @returns The clamped value.
  89085. */
  89086. private static clamp;
  89087. /**
  89088. * Clones the current color curve instance.
  89089. * @return The cloned curves
  89090. */
  89091. clone(): ColorCurves;
  89092. /**
  89093. * Serializes the current color curve instance to a json representation.
  89094. * @return a JSON representation
  89095. */
  89096. serialize(): any;
  89097. /**
  89098. * Parses the color curve from a json representation.
  89099. * @param source the JSON source to parse
  89100. * @return The parsed curves
  89101. */
  89102. static Parse(source: any): ColorCurves;
  89103. }
  89104. }
  89105. declare module BABYLON {
  89106. /**
  89107. * Interface to follow in your material defines to integrate easily the
  89108. * Image proccessing functions.
  89109. * @hidden
  89110. */
  89111. export interface IImageProcessingConfigurationDefines {
  89112. IMAGEPROCESSING: boolean;
  89113. VIGNETTE: boolean;
  89114. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89115. VIGNETTEBLENDMODEOPAQUE: boolean;
  89116. TONEMAPPING: boolean;
  89117. TONEMAPPING_ACES: boolean;
  89118. CONTRAST: boolean;
  89119. EXPOSURE: boolean;
  89120. COLORCURVES: boolean;
  89121. COLORGRADING: boolean;
  89122. COLORGRADING3D: boolean;
  89123. SAMPLER3DGREENDEPTH: boolean;
  89124. SAMPLER3DBGRMAP: boolean;
  89125. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89126. }
  89127. /**
  89128. * @hidden
  89129. */
  89130. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89131. IMAGEPROCESSING: boolean;
  89132. VIGNETTE: boolean;
  89133. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89134. VIGNETTEBLENDMODEOPAQUE: boolean;
  89135. TONEMAPPING: boolean;
  89136. TONEMAPPING_ACES: boolean;
  89137. CONTRAST: boolean;
  89138. COLORCURVES: boolean;
  89139. COLORGRADING: boolean;
  89140. COLORGRADING3D: boolean;
  89141. SAMPLER3DGREENDEPTH: boolean;
  89142. SAMPLER3DBGRMAP: boolean;
  89143. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89144. EXPOSURE: boolean;
  89145. constructor();
  89146. }
  89147. /**
  89148. * This groups together the common properties used for image processing either in direct forward pass
  89149. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89150. * or not.
  89151. */
  89152. export class ImageProcessingConfiguration {
  89153. /**
  89154. * Default tone mapping applied in BabylonJS.
  89155. */
  89156. static readonly TONEMAPPING_STANDARD: number;
  89157. /**
  89158. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89159. * to other engines rendering to increase portability.
  89160. */
  89161. static readonly TONEMAPPING_ACES: number;
  89162. /**
  89163. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89164. */
  89165. colorCurves: Nullable<ColorCurves>;
  89166. private _colorCurvesEnabled;
  89167. /**
  89168. * Gets wether the color curves effect is enabled.
  89169. */
  89170. /**
  89171. * Sets wether the color curves effect is enabled.
  89172. */
  89173. colorCurvesEnabled: boolean;
  89174. private _colorGradingTexture;
  89175. /**
  89176. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89177. */
  89178. /**
  89179. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89180. */
  89181. colorGradingTexture: Nullable<BaseTexture>;
  89182. private _colorGradingEnabled;
  89183. /**
  89184. * Gets wether the color grading effect is enabled.
  89185. */
  89186. /**
  89187. * Sets wether the color grading effect is enabled.
  89188. */
  89189. colorGradingEnabled: boolean;
  89190. private _colorGradingWithGreenDepth;
  89191. /**
  89192. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89193. */
  89194. /**
  89195. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89196. */
  89197. colorGradingWithGreenDepth: boolean;
  89198. private _colorGradingBGR;
  89199. /**
  89200. * Gets wether the color grading texture contains BGR values.
  89201. */
  89202. /**
  89203. * Sets wether the color grading texture contains BGR values.
  89204. */
  89205. colorGradingBGR: boolean;
  89206. /** @hidden */
  89207. _exposure: number;
  89208. /**
  89209. * Gets the Exposure used in the effect.
  89210. */
  89211. /**
  89212. * Sets the Exposure used in the effect.
  89213. */
  89214. exposure: number;
  89215. private _toneMappingEnabled;
  89216. /**
  89217. * Gets wether the tone mapping effect is enabled.
  89218. */
  89219. /**
  89220. * Sets wether the tone mapping effect is enabled.
  89221. */
  89222. toneMappingEnabled: boolean;
  89223. private _toneMappingType;
  89224. /**
  89225. * Gets the type of tone mapping effect.
  89226. */
  89227. /**
  89228. * Sets the type of tone mapping effect used in BabylonJS.
  89229. */
  89230. toneMappingType: number;
  89231. protected _contrast: number;
  89232. /**
  89233. * Gets the contrast used in the effect.
  89234. */
  89235. /**
  89236. * Sets the contrast used in the effect.
  89237. */
  89238. contrast: number;
  89239. /**
  89240. * Vignette stretch size.
  89241. */
  89242. vignetteStretch: number;
  89243. /**
  89244. * Vignette centre X Offset.
  89245. */
  89246. vignetteCentreX: number;
  89247. /**
  89248. * Vignette centre Y Offset.
  89249. */
  89250. vignetteCentreY: number;
  89251. /**
  89252. * Vignette weight or intensity of the vignette effect.
  89253. */
  89254. vignetteWeight: number;
  89255. /**
  89256. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89257. * if vignetteEnabled is set to true.
  89258. */
  89259. vignetteColor: Color4;
  89260. /**
  89261. * Camera field of view used by the Vignette effect.
  89262. */
  89263. vignetteCameraFov: number;
  89264. private _vignetteBlendMode;
  89265. /**
  89266. * Gets the vignette blend mode allowing different kind of effect.
  89267. */
  89268. /**
  89269. * Sets the vignette blend mode allowing different kind of effect.
  89270. */
  89271. vignetteBlendMode: number;
  89272. private _vignetteEnabled;
  89273. /**
  89274. * Gets wether the vignette effect is enabled.
  89275. */
  89276. /**
  89277. * Sets wether the vignette effect is enabled.
  89278. */
  89279. vignetteEnabled: boolean;
  89280. private _applyByPostProcess;
  89281. /**
  89282. * Gets wether the image processing is applied through a post process or not.
  89283. */
  89284. /**
  89285. * Sets wether the image processing is applied through a post process or not.
  89286. */
  89287. applyByPostProcess: boolean;
  89288. private _isEnabled;
  89289. /**
  89290. * Gets wether the image processing is enabled or not.
  89291. */
  89292. /**
  89293. * Sets wether the image processing is enabled or not.
  89294. */
  89295. isEnabled: boolean;
  89296. /**
  89297. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89298. */
  89299. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89300. /**
  89301. * Method called each time the image processing information changes requires to recompile the effect.
  89302. */
  89303. protected _updateParameters(): void;
  89304. /**
  89305. * Gets the current class name.
  89306. * @return "ImageProcessingConfiguration"
  89307. */
  89308. getClassName(): string;
  89309. /**
  89310. * Prepare the list of uniforms associated with the Image Processing effects.
  89311. * @param uniforms The list of uniforms used in the effect
  89312. * @param defines the list of defines currently in use
  89313. */
  89314. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89315. /**
  89316. * Prepare the list of samplers associated with the Image Processing effects.
  89317. * @param samplersList The list of uniforms used in the effect
  89318. * @param defines the list of defines currently in use
  89319. */
  89320. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89321. /**
  89322. * Prepare the list of defines associated to the shader.
  89323. * @param defines the list of defines to complete
  89324. * @param forPostProcess Define if we are currently in post process mode or not
  89325. */
  89326. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89327. /**
  89328. * Returns true if all the image processing information are ready.
  89329. * @returns True if ready, otherwise, false
  89330. */
  89331. isReady(): boolean;
  89332. /**
  89333. * Binds the image processing to the shader.
  89334. * @param effect The effect to bind to
  89335. * @param aspectRatio Define the current aspect ratio of the effect
  89336. */
  89337. bind(effect: Effect, aspectRatio?: number): void;
  89338. /**
  89339. * Clones the current image processing instance.
  89340. * @return The cloned image processing
  89341. */
  89342. clone(): ImageProcessingConfiguration;
  89343. /**
  89344. * Serializes the current image processing instance to a json representation.
  89345. * @return a JSON representation
  89346. */
  89347. serialize(): any;
  89348. /**
  89349. * Parses the image processing from a json representation.
  89350. * @param source the JSON source to parse
  89351. * @return The parsed image processing
  89352. */
  89353. static Parse(source: any): ImageProcessingConfiguration;
  89354. private static _VIGNETTEMODE_MULTIPLY;
  89355. private static _VIGNETTEMODE_OPAQUE;
  89356. /**
  89357. * Used to apply the vignette as a mix with the pixel color.
  89358. */
  89359. static readonly VIGNETTEMODE_MULTIPLY: number;
  89360. /**
  89361. * Used to apply the vignette as a replacement of the pixel color.
  89362. */
  89363. static readonly VIGNETTEMODE_OPAQUE: number;
  89364. }
  89365. }
  89366. declare module BABYLON {
  89367. /**
  89368. * This represents all the required information to add a fresnel effect on a material:
  89369. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89370. */
  89371. export class FresnelParameters {
  89372. private _isEnabled;
  89373. /**
  89374. * Define if the fresnel effect is enable or not.
  89375. */
  89376. isEnabled: boolean;
  89377. /**
  89378. * Define the color used on edges (grazing angle)
  89379. */
  89380. leftColor: Color3;
  89381. /**
  89382. * Define the color used on center
  89383. */
  89384. rightColor: Color3;
  89385. /**
  89386. * Define bias applied to computed fresnel term
  89387. */
  89388. bias: number;
  89389. /**
  89390. * Defined the power exponent applied to fresnel term
  89391. */
  89392. power: number;
  89393. /**
  89394. * Clones the current fresnel and its valuues
  89395. * @returns a clone fresnel configuration
  89396. */
  89397. clone(): FresnelParameters;
  89398. /**
  89399. * Serializes the current fresnel parameters to a JSON representation.
  89400. * @return the JSON serialization
  89401. */
  89402. serialize(): any;
  89403. /**
  89404. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89405. * @param parsedFresnelParameters Define the JSON representation
  89406. * @returns the parsed parameters
  89407. */
  89408. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89409. }
  89410. }
  89411. declare module BABYLON {
  89412. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89413. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89414. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89415. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89416. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89417. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89418. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89419. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89420. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89421. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89422. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89423. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89424. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89425. /**
  89426. * Decorator used to define property that can be serialized as reference to a camera
  89427. * @param sourceName defines the name of the property to decorate
  89428. */
  89429. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89430. /**
  89431. * Class used to help serialization objects
  89432. */
  89433. export class SerializationHelper {
  89434. /** hidden */
  89435. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89436. /** hidden */
  89437. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89438. /** hidden */
  89439. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89440. /** hidden */
  89441. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89442. /**
  89443. * Appends the serialized animations from the source animations
  89444. * @param source Source containing the animations
  89445. * @param destination Target to store the animations
  89446. */
  89447. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89448. /**
  89449. * Static function used to serialized a specific entity
  89450. * @param entity defines the entity to serialize
  89451. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89452. * @returns a JSON compatible object representing the serialization of the entity
  89453. */
  89454. static Serialize<T>(entity: T, serializationObject?: any): any;
  89455. /**
  89456. * Creates a new entity from a serialization data object
  89457. * @param creationFunction defines a function used to instanciated the new entity
  89458. * @param source defines the source serialization data
  89459. * @param scene defines the hosting scene
  89460. * @param rootUrl defines the root url for resources
  89461. * @returns a new entity
  89462. */
  89463. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89464. /**
  89465. * Clones an object
  89466. * @param creationFunction defines the function used to instanciate the new object
  89467. * @param source defines the source object
  89468. * @returns the cloned object
  89469. */
  89470. static Clone<T>(creationFunction: () => T, source: T): T;
  89471. /**
  89472. * Instanciates a new object based on a source one (some data will be shared between both object)
  89473. * @param creationFunction defines the function used to instanciate the new object
  89474. * @param source defines the source object
  89475. * @returns the new object
  89476. */
  89477. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89478. }
  89479. }
  89480. declare module BABYLON {
  89481. /**
  89482. * This is the base class of all the camera used in the application.
  89483. * @see http://doc.babylonjs.com/features/cameras
  89484. */
  89485. export class Camera extends Node {
  89486. /** @hidden */
  89487. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89488. /**
  89489. * This is the default projection mode used by the cameras.
  89490. * It helps recreating a feeling of perspective and better appreciate depth.
  89491. * This is the best way to simulate real life cameras.
  89492. */
  89493. static readonly PERSPECTIVE_CAMERA: number;
  89494. /**
  89495. * This helps creating camera with an orthographic mode.
  89496. * 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.
  89497. */
  89498. static readonly ORTHOGRAPHIC_CAMERA: number;
  89499. /**
  89500. * This is the default FOV mode for perspective cameras.
  89501. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89502. */
  89503. static readonly FOVMODE_VERTICAL_FIXED: number;
  89504. /**
  89505. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89506. */
  89507. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89508. /**
  89509. * This specifies ther is no need for a camera rig.
  89510. * Basically only one eye is rendered corresponding to the camera.
  89511. */
  89512. static readonly RIG_MODE_NONE: number;
  89513. /**
  89514. * Simulates a camera Rig with one blue eye and one red eye.
  89515. * This can be use with 3d blue and red glasses.
  89516. */
  89517. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89518. /**
  89519. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89520. */
  89521. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89522. /**
  89523. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89524. */
  89525. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89526. /**
  89527. * Defines that both eyes of the camera will be rendered over under each other.
  89528. */
  89529. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89530. /**
  89531. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89532. */
  89533. static readonly RIG_MODE_VR: number;
  89534. /**
  89535. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89536. */
  89537. static readonly RIG_MODE_WEBVR: number;
  89538. /**
  89539. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89540. */
  89541. static readonly RIG_MODE_CUSTOM: number;
  89542. /**
  89543. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89544. */
  89545. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89546. /**
  89547. * Define the input manager associated with the camera.
  89548. */
  89549. inputs: CameraInputsManager<Camera>;
  89550. /** @hidden */
  89551. _position: Vector3;
  89552. /**
  89553. * Define the current local position of the camera in the scene
  89554. */
  89555. position: Vector3;
  89556. /**
  89557. * The vector the camera should consider as up.
  89558. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89559. */
  89560. upVector: Vector3;
  89561. /**
  89562. * Define the current limit on the left side for an orthographic camera
  89563. * In scene unit
  89564. */
  89565. orthoLeft: Nullable<number>;
  89566. /**
  89567. * Define the current limit on the right side for an orthographic camera
  89568. * In scene unit
  89569. */
  89570. orthoRight: Nullable<number>;
  89571. /**
  89572. * Define the current limit on the bottom side for an orthographic camera
  89573. * In scene unit
  89574. */
  89575. orthoBottom: Nullable<number>;
  89576. /**
  89577. * Define the current limit on the top side for an orthographic camera
  89578. * In scene unit
  89579. */
  89580. orthoTop: Nullable<number>;
  89581. /**
  89582. * Field Of View is set in Radians. (default is 0.8)
  89583. */
  89584. fov: number;
  89585. /**
  89586. * Define the minimum distance the camera can see from.
  89587. * This is important to note that the depth buffer are not infinite and the closer it starts
  89588. * the more your scene might encounter depth fighting issue.
  89589. */
  89590. minZ: number;
  89591. /**
  89592. * Define the maximum distance the camera can see to.
  89593. * This is important to note that the depth buffer are not infinite and the further it end
  89594. * the more your scene might encounter depth fighting issue.
  89595. */
  89596. maxZ: number;
  89597. /**
  89598. * Define the default inertia of the camera.
  89599. * This helps giving a smooth feeling to the camera movement.
  89600. */
  89601. inertia: number;
  89602. /**
  89603. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89604. */
  89605. mode: number;
  89606. /**
  89607. * Define wether the camera is intermediate.
  89608. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89609. */
  89610. isIntermediate: boolean;
  89611. /**
  89612. * Define the viewport of the camera.
  89613. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89614. */
  89615. viewport: Viewport;
  89616. /**
  89617. * Restricts the camera to viewing objects with the same layerMask.
  89618. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89619. */
  89620. layerMask: number;
  89621. /**
  89622. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89623. */
  89624. fovMode: number;
  89625. /**
  89626. * Rig mode of the camera.
  89627. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89628. * This is normally controlled byt the camera themselves as internal use.
  89629. */
  89630. cameraRigMode: number;
  89631. /**
  89632. * Defines the distance between both "eyes" in case of a RIG
  89633. */
  89634. interaxialDistance: number;
  89635. /**
  89636. * Defines if stereoscopic rendering is done side by side or over under.
  89637. */
  89638. isStereoscopicSideBySide: boolean;
  89639. /**
  89640. * 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
  89641. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89642. * else in the scene.
  89643. */
  89644. customRenderTargets: RenderTargetTexture[];
  89645. /**
  89646. * When set, the camera will render to this render target instead of the default canvas
  89647. */
  89648. outputRenderTarget: Nullable<RenderTargetTexture>;
  89649. /**
  89650. * Observable triggered when the camera view matrix has changed.
  89651. */
  89652. onViewMatrixChangedObservable: Observable<Camera>;
  89653. /**
  89654. * Observable triggered when the camera Projection matrix has changed.
  89655. */
  89656. onProjectionMatrixChangedObservable: Observable<Camera>;
  89657. /**
  89658. * Observable triggered when the inputs have been processed.
  89659. */
  89660. onAfterCheckInputsObservable: Observable<Camera>;
  89661. /**
  89662. * Observable triggered when reset has been called and applied to the camera.
  89663. */
  89664. onRestoreStateObservable: Observable<Camera>;
  89665. /** @hidden */
  89666. _cameraRigParams: any;
  89667. /** @hidden */
  89668. _rigCameras: Camera[];
  89669. /** @hidden */
  89670. _rigPostProcess: Nullable<PostProcess>;
  89671. protected _webvrViewMatrix: Matrix;
  89672. /** @hidden */
  89673. _skipRendering: boolean;
  89674. /** @hidden */
  89675. _projectionMatrix: Matrix;
  89676. /** @hidden */
  89677. _postProcesses: Nullable<PostProcess>[];
  89678. /** @hidden */
  89679. _activeMeshes: SmartArray<AbstractMesh>;
  89680. protected _globalPosition: Vector3;
  89681. /** hidden */
  89682. _computedViewMatrix: Matrix;
  89683. private _doNotComputeProjectionMatrix;
  89684. private _transformMatrix;
  89685. private _frustumPlanes;
  89686. private _refreshFrustumPlanes;
  89687. private _storedFov;
  89688. private _stateStored;
  89689. /**
  89690. * Instantiates a new camera object.
  89691. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89692. * @see http://doc.babylonjs.com/features/cameras
  89693. * @param name Defines the name of the camera in the scene
  89694. * @param position Defines the position of the camera
  89695. * @param scene Defines the scene the camera belongs too
  89696. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89697. */
  89698. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89699. /**
  89700. * Store current camera state (fov, position, etc..)
  89701. * @returns the camera
  89702. */
  89703. storeState(): Camera;
  89704. /**
  89705. * Restores the camera state values if it has been stored. You must call storeState() first
  89706. */
  89707. protected _restoreStateValues(): boolean;
  89708. /**
  89709. * Restored camera state. You must call storeState() first.
  89710. * @returns true if restored and false otherwise
  89711. */
  89712. restoreState(): boolean;
  89713. /**
  89714. * Gets the class name of the camera.
  89715. * @returns the class name
  89716. */
  89717. getClassName(): string;
  89718. /** @hidden */
  89719. readonly _isCamera: boolean;
  89720. /**
  89721. * Gets a string representation of the camera useful for debug purpose.
  89722. * @param fullDetails Defines that a more verboe level of logging is required
  89723. * @returns the string representation
  89724. */
  89725. toString(fullDetails?: boolean): string;
  89726. /**
  89727. * Gets the current world space position of the camera.
  89728. */
  89729. readonly globalPosition: Vector3;
  89730. /**
  89731. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89732. * @returns the active meshe list
  89733. */
  89734. getActiveMeshes(): SmartArray<AbstractMesh>;
  89735. /**
  89736. * Check wether a mesh is part of the current active mesh list of the camera
  89737. * @param mesh Defines the mesh to check
  89738. * @returns true if active, false otherwise
  89739. */
  89740. isActiveMesh(mesh: Mesh): boolean;
  89741. /**
  89742. * Is this camera ready to be used/rendered
  89743. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89744. * @return true if the camera is ready
  89745. */
  89746. isReady(completeCheck?: boolean): boolean;
  89747. /** @hidden */
  89748. _initCache(): void;
  89749. /** @hidden */
  89750. _updateCache(ignoreParentClass?: boolean): void;
  89751. /** @hidden */
  89752. _isSynchronized(): boolean;
  89753. /** @hidden */
  89754. _isSynchronizedViewMatrix(): boolean;
  89755. /** @hidden */
  89756. _isSynchronizedProjectionMatrix(): boolean;
  89757. /**
  89758. * Attach the input controls to a specific dom element to get the input from.
  89759. * @param element Defines the element the controls should be listened from
  89760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89761. */
  89762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89763. /**
  89764. * Detach the current controls from the specified dom element.
  89765. * @param element Defines the element to stop listening the inputs from
  89766. */
  89767. detachControl(element: HTMLElement): void;
  89768. /**
  89769. * Update the camera state according to the different inputs gathered during the frame.
  89770. */
  89771. update(): void;
  89772. /** @hidden */
  89773. _checkInputs(): void;
  89774. /** @hidden */
  89775. readonly rigCameras: Camera[];
  89776. /**
  89777. * Gets the post process used by the rig cameras
  89778. */
  89779. readonly rigPostProcess: Nullable<PostProcess>;
  89780. /**
  89781. * Internal, gets the first post proces.
  89782. * @returns the first post process to be run on this camera.
  89783. */
  89784. _getFirstPostProcess(): Nullable<PostProcess>;
  89785. private _cascadePostProcessesToRigCams;
  89786. /**
  89787. * Attach a post process to the camera.
  89788. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89789. * @param postProcess The post process to attach to the camera
  89790. * @param insertAt The position of the post process in case several of them are in use in the scene
  89791. * @returns the position the post process has been inserted at
  89792. */
  89793. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89794. /**
  89795. * Detach a post process to the camera.
  89796. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89797. * @param postProcess The post process to detach from the camera
  89798. */
  89799. detachPostProcess(postProcess: PostProcess): void;
  89800. /**
  89801. * Gets the current world matrix of the camera
  89802. */
  89803. getWorldMatrix(): Matrix;
  89804. /** @hidden */
  89805. _getViewMatrix(): Matrix;
  89806. /**
  89807. * Gets the current view matrix of the camera.
  89808. * @param force forces the camera to recompute the matrix without looking at the cached state
  89809. * @returns the view matrix
  89810. */
  89811. getViewMatrix(force?: boolean): Matrix;
  89812. /**
  89813. * Freeze the projection matrix.
  89814. * It will prevent the cache check of the camera projection compute and can speed up perf
  89815. * if no parameter of the camera are meant to change
  89816. * @param projection Defines manually a projection if necessary
  89817. */
  89818. freezeProjectionMatrix(projection?: Matrix): void;
  89819. /**
  89820. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  89821. */
  89822. unfreezeProjectionMatrix(): void;
  89823. /**
  89824. * Gets the current projection matrix of the camera.
  89825. * @param force forces the camera to recompute the matrix without looking at the cached state
  89826. * @returns the projection matrix
  89827. */
  89828. getProjectionMatrix(force?: boolean): Matrix;
  89829. /**
  89830. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  89831. * @returns a Matrix
  89832. */
  89833. getTransformationMatrix(): Matrix;
  89834. private _updateFrustumPlanes;
  89835. /**
  89836. * Checks if a cullable object (mesh...) is in the camera frustum
  89837. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  89838. * @param target The object to check
  89839. * @returns true if the object is in frustum otherwise false
  89840. */
  89841. isInFrustum(target: ICullable): boolean;
  89842. /**
  89843. * Checks if a cullable object (mesh...) is in the camera frustum
  89844. * Unlike isInFrustum this cheks the full bounding box
  89845. * @param target The object to check
  89846. * @returns true if the object is in frustum otherwise false
  89847. */
  89848. isCompletelyInFrustum(target: ICullable): boolean;
  89849. /**
  89850. * Gets a ray in the forward direction from the camera.
  89851. * @param length Defines the length of the ray to create
  89852. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  89853. * @param origin Defines the start point of the ray which defaults to the camera position
  89854. * @returns the forward ray
  89855. */
  89856. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  89857. /**
  89858. * Releases resources associated with this node.
  89859. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  89860. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  89861. */
  89862. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89863. /** @hidden */
  89864. _isLeftCamera: boolean;
  89865. /**
  89866. * Gets the left camera of a rig setup in case of Rigged Camera
  89867. */
  89868. readonly isLeftCamera: boolean;
  89869. /** @hidden */
  89870. _isRightCamera: boolean;
  89871. /**
  89872. * Gets the right camera of a rig setup in case of Rigged Camera
  89873. */
  89874. readonly isRightCamera: boolean;
  89875. /**
  89876. * Gets the left camera of a rig setup in case of Rigged Camera
  89877. */
  89878. readonly leftCamera: Nullable<FreeCamera>;
  89879. /**
  89880. * Gets the right camera of a rig setup in case of Rigged Camera
  89881. */
  89882. readonly rightCamera: Nullable<FreeCamera>;
  89883. /**
  89884. * Gets the left camera target of a rig setup in case of Rigged Camera
  89885. * @returns the target position
  89886. */
  89887. getLeftTarget(): Nullable<Vector3>;
  89888. /**
  89889. * Gets the right camera target of a rig setup in case of Rigged Camera
  89890. * @returns the target position
  89891. */
  89892. getRightTarget(): Nullable<Vector3>;
  89893. /**
  89894. * @hidden
  89895. */
  89896. setCameraRigMode(mode: number, rigParams: any): void;
  89897. /** @hidden */
  89898. static _setStereoscopicRigMode(camera: Camera): void;
  89899. /** @hidden */
  89900. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  89901. /** @hidden */
  89902. static _setVRRigMode(camera: Camera, rigParams: any): void;
  89903. /** @hidden */
  89904. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  89905. /** @hidden */
  89906. _getVRProjectionMatrix(): Matrix;
  89907. protected _updateCameraRotationMatrix(): void;
  89908. protected _updateWebVRCameraRotationMatrix(): void;
  89909. /**
  89910. * This function MUST be overwritten by the different WebVR cameras available.
  89911. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89912. * @hidden
  89913. */
  89914. _getWebVRProjectionMatrix(): Matrix;
  89915. /**
  89916. * This function MUST be overwritten by the different WebVR cameras available.
  89917. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  89918. * @hidden
  89919. */
  89920. _getWebVRViewMatrix(): Matrix;
  89921. /** @hidden */
  89922. setCameraRigParameter(name: string, value: any): void;
  89923. /**
  89924. * needs to be overridden by children so sub has required properties to be copied
  89925. * @hidden
  89926. */
  89927. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  89928. /**
  89929. * May need to be overridden by children
  89930. * @hidden
  89931. */
  89932. _updateRigCameras(): void;
  89933. /** @hidden */
  89934. _setupInputs(): void;
  89935. /**
  89936. * Serialiaze the camera setup to a json represention
  89937. * @returns the JSON representation
  89938. */
  89939. serialize(): any;
  89940. /**
  89941. * Clones the current camera.
  89942. * @param name The cloned camera name
  89943. * @returns the cloned camera
  89944. */
  89945. clone(name: string): Camera;
  89946. /**
  89947. * Gets the direction of the camera relative to a given local axis.
  89948. * @param localAxis Defines the reference axis to provide a relative direction.
  89949. * @return the direction
  89950. */
  89951. getDirection(localAxis: Vector3): Vector3;
  89952. /**
  89953. * Gets the direction of the camera relative to a given local axis into a passed vector.
  89954. * @param localAxis Defines the reference axis to provide a relative direction.
  89955. * @param result Defines the vector to store the result in
  89956. */
  89957. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  89958. /**
  89959. * Gets a camera constructor for a given camera type
  89960. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  89961. * @param name The name of the camera the result will be able to instantiate
  89962. * @param scene The scene the result will construct the camera in
  89963. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  89964. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  89965. * @returns a factory method to construc the camera
  89966. */
  89967. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  89968. /**
  89969. * Compute the world matrix of the camera.
  89970. * @returns the camera workd matrix
  89971. */
  89972. computeWorldMatrix(): Matrix;
  89973. /**
  89974. * Parse a JSON and creates the camera from the parsed information
  89975. * @param parsedCamera The JSON to parse
  89976. * @param scene The scene to instantiate the camera in
  89977. * @returns the newly constructed camera
  89978. */
  89979. static Parse(parsedCamera: any, scene: Scene): Camera;
  89980. }
  89981. }
  89982. declare module BABYLON {
  89983. /**
  89984. * Interface for any object that can request an animation frame
  89985. */
  89986. export interface ICustomAnimationFrameRequester {
  89987. /**
  89988. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  89989. */
  89990. renderFunction?: Function;
  89991. /**
  89992. * Called to request the next frame to render to
  89993. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  89994. */
  89995. requestAnimationFrame: Function;
  89996. /**
  89997. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  89998. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  89999. */
  90000. requestID?: number;
  90001. }
  90002. /**
  90003. * Interface containing an array of animations
  90004. */
  90005. export interface IAnimatable {
  90006. /**
  90007. * Array of animations
  90008. */
  90009. animations: Nullable<Array<Animation>>;
  90010. }
  90011. /** Interface used by value gradients (color, factor, ...) */
  90012. export interface IValueGradient {
  90013. /**
  90014. * Gets or sets the gradient value (between 0 and 1)
  90015. */
  90016. gradient: number;
  90017. }
  90018. /** Class used to store color4 gradient */
  90019. export class ColorGradient implements IValueGradient {
  90020. /**
  90021. * Gets or sets the gradient value (between 0 and 1)
  90022. */
  90023. gradient: number;
  90024. /**
  90025. * Gets or sets first associated color
  90026. */
  90027. color1: Color4;
  90028. /**
  90029. * Gets or sets second associated color
  90030. */
  90031. color2?: Color4;
  90032. /**
  90033. * Will get a color picked randomly between color1 and color2.
  90034. * If color2 is undefined then color1 will be used
  90035. * @param result defines the target Color4 to store the result in
  90036. */
  90037. getColorToRef(result: Color4): void;
  90038. }
  90039. /** Class used to store color 3 gradient */
  90040. export class Color3Gradient implements IValueGradient {
  90041. /**
  90042. * Gets or sets the gradient value (between 0 and 1)
  90043. */
  90044. gradient: number;
  90045. /**
  90046. * Gets or sets the associated color
  90047. */
  90048. color: Color3;
  90049. }
  90050. /** Class used to store factor gradient */
  90051. export class FactorGradient implements IValueGradient {
  90052. /**
  90053. * Gets or sets the gradient value (between 0 and 1)
  90054. */
  90055. gradient: number;
  90056. /**
  90057. * Gets or sets first associated factor
  90058. */
  90059. factor1: number;
  90060. /**
  90061. * Gets or sets second associated factor
  90062. */
  90063. factor2?: number;
  90064. /**
  90065. * Will get a number picked randomly between factor1 and factor2.
  90066. * If factor2 is undefined then factor1 will be used
  90067. * @returns the picked number
  90068. */
  90069. getFactor(): number;
  90070. }
  90071. /**
  90072. * @ignore
  90073. * Application error to support additional information when loading a file
  90074. */
  90075. export class LoadFileError extends Error {
  90076. /** defines the optional web request */
  90077. request?: WebRequest | undefined;
  90078. private static _setPrototypeOf;
  90079. /**
  90080. * Creates a new LoadFileError
  90081. * @param message defines the message of the error
  90082. * @param request defines the optional web request
  90083. */
  90084. constructor(message: string,
  90085. /** defines the optional web request */
  90086. request?: WebRequest | undefined);
  90087. }
  90088. /**
  90089. * Class used to define a retry strategy when error happens while loading assets
  90090. */
  90091. export class RetryStrategy {
  90092. /**
  90093. * Function used to defines an exponential back off strategy
  90094. * @param maxRetries defines the maximum number of retries (3 by default)
  90095. * @param baseInterval defines the interval between retries
  90096. * @returns the strategy function to use
  90097. */
  90098. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90099. }
  90100. /**
  90101. * File request interface
  90102. */
  90103. export interface IFileRequest {
  90104. /**
  90105. * Raised when the request is complete (success or error).
  90106. */
  90107. onCompleteObservable: Observable<IFileRequest>;
  90108. /**
  90109. * Aborts the request for a file.
  90110. */
  90111. abort: () => void;
  90112. }
  90113. /**
  90114. * Class containing a set of static utilities functions
  90115. */
  90116. export class Tools {
  90117. /**
  90118. * Gets or sets the base URL to use to load assets
  90119. */
  90120. static BaseUrl: string;
  90121. /**
  90122. * Enable/Disable Custom HTTP Request Headers globally.
  90123. * default = false
  90124. * @see CustomRequestHeaders
  90125. */
  90126. static UseCustomRequestHeaders: boolean;
  90127. /**
  90128. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90129. * i.e. when loading files, where the server/service expects an Authorization header
  90130. */
  90131. static CustomRequestHeaders: {
  90132. [key: string]: string;
  90133. };
  90134. /**
  90135. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90136. */
  90137. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90138. /**
  90139. * Default behaviour for cors in the application.
  90140. * It can be a string if the expected behavior is identical in the entire app.
  90141. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90142. */
  90143. static CorsBehavior: string | ((url: string | string[]) => string);
  90144. /**
  90145. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90146. * @ignorenaming
  90147. */
  90148. static UseFallbackTexture: boolean;
  90149. /**
  90150. * Use this object to register external classes like custom textures or material
  90151. * to allow the laoders to instantiate them
  90152. */
  90153. static RegisteredExternalClasses: {
  90154. [key: string]: Object;
  90155. };
  90156. /**
  90157. * Texture content used if a texture cannot loaded
  90158. * @ignorenaming
  90159. */
  90160. static fallbackTexture: string;
  90161. /**
  90162. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90163. * @param u defines the coordinate on X axis
  90164. * @param v defines the coordinate on Y axis
  90165. * @param width defines the width of the source data
  90166. * @param height defines the height of the source data
  90167. * @param pixels defines the source byte array
  90168. * @param color defines the output color
  90169. */
  90170. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90171. /**
  90172. * Interpolates between a and b via alpha
  90173. * @param a The lower value (returned when alpha = 0)
  90174. * @param b The upper value (returned when alpha = 1)
  90175. * @param alpha The interpolation-factor
  90176. * @return The mixed value
  90177. */
  90178. static Mix(a: number, b: number, alpha: number): number;
  90179. /**
  90180. * Tries to instantiate a new object from a given class name
  90181. * @param className defines the class name to instantiate
  90182. * @returns the new object or null if the system was not able to do the instantiation
  90183. */
  90184. static Instantiate(className: string): any;
  90185. /**
  90186. * Provides a slice function that will work even on IE
  90187. * @param data defines the array to slice
  90188. * @param start defines the start of the data (optional)
  90189. * @param end defines the end of the data (optional)
  90190. * @returns the new sliced array
  90191. */
  90192. static Slice<T>(data: T, start?: number, end?: number): T;
  90193. /**
  90194. * Polyfill for setImmediate
  90195. * @param action defines the action to execute after the current execution block
  90196. */
  90197. static SetImmediate(action: () => void): void;
  90198. /**
  90199. * Function indicating if a number is an exponent of 2
  90200. * @param value defines the value to test
  90201. * @returns true if the value is an exponent of 2
  90202. */
  90203. static IsExponentOfTwo(value: number): boolean;
  90204. private static _tmpFloatArray;
  90205. /**
  90206. * Returns the nearest 32-bit single precision float representation of a Number
  90207. * @param value A Number. If the parameter is of a different type, it will get converted
  90208. * to a number or to NaN if it cannot be converted
  90209. * @returns number
  90210. */
  90211. static FloatRound(value: number): number;
  90212. /**
  90213. * Find the next highest power of two.
  90214. * @param x Number to start search from.
  90215. * @return Next highest power of two.
  90216. */
  90217. static CeilingPOT(x: number): number;
  90218. /**
  90219. * Find the next lowest power of two.
  90220. * @param x Number to start search from.
  90221. * @return Next lowest power of two.
  90222. */
  90223. static FloorPOT(x: number): number;
  90224. /**
  90225. * Find the nearest power of two.
  90226. * @param x Number to start search from.
  90227. * @return Next nearest power of two.
  90228. */
  90229. static NearestPOT(x: number): number;
  90230. /**
  90231. * Get the closest exponent of two
  90232. * @param value defines the value to approximate
  90233. * @param max defines the maximum value to return
  90234. * @param mode defines how to define the closest value
  90235. * @returns closest exponent of two of the given value
  90236. */
  90237. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90238. /**
  90239. * Extracts the filename from a path
  90240. * @param path defines the path to use
  90241. * @returns the filename
  90242. */
  90243. static GetFilename(path: string): string;
  90244. /**
  90245. * Extracts the "folder" part of a path (everything before the filename).
  90246. * @param uri The URI to extract the info from
  90247. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90248. * @returns The "folder" part of the path
  90249. */
  90250. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90251. /**
  90252. * Extracts text content from a DOM element hierarchy
  90253. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90254. */
  90255. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90256. /**
  90257. * Convert an angle in radians to degrees
  90258. * @param angle defines the angle to convert
  90259. * @returns the angle in degrees
  90260. */
  90261. static ToDegrees(angle: number): number;
  90262. /**
  90263. * Convert an angle in degrees to radians
  90264. * @param angle defines the angle to convert
  90265. * @returns the angle in radians
  90266. */
  90267. static ToRadians(angle: number): number;
  90268. /**
  90269. * Encode a buffer to a base64 string
  90270. * @param buffer defines the buffer to encode
  90271. * @returns the encoded string
  90272. */
  90273. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90274. /**
  90275. * Extracts minimum and maximum values from a list of indexed positions
  90276. * @param positions defines the positions to use
  90277. * @param indices defines the indices to the positions
  90278. * @param indexStart defines the start index
  90279. * @param indexCount defines the end index
  90280. * @param bias defines bias value to add to the result
  90281. * @return minimum and maximum values
  90282. */
  90283. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90284. minimum: Vector3;
  90285. maximum: Vector3;
  90286. };
  90287. /**
  90288. * Extracts minimum and maximum values from a list of positions
  90289. * @param positions defines the positions to use
  90290. * @param start defines the start index in the positions array
  90291. * @param count defines the number of positions to handle
  90292. * @param bias defines bias value to add to the result
  90293. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90294. * @return minimum and maximum values
  90295. */
  90296. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90297. minimum: Vector3;
  90298. maximum: Vector3;
  90299. };
  90300. /**
  90301. * Returns an array if obj is not an array
  90302. * @param obj defines the object to evaluate as an array
  90303. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90304. * @returns either obj directly if obj is an array or a new array containing obj
  90305. */
  90306. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90307. /**
  90308. * Gets the pointer prefix to use
  90309. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90310. */
  90311. static GetPointerPrefix(): string;
  90312. /**
  90313. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90314. * @param func - the function to be called
  90315. * @param requester - the object that will request the next frame. Falls back to window.
  90316. * @returns frame number
  90317. */
  90318. static QueueNewFrame(func: () => void, requester?: any): number;
  90319. /**
  90320. * Ask the browser to promote the current element to fullscreen rendering mode
  90321. * @param element defines the DOM element to promote
  90322. */
  90323. static RequestFullscreen(element: HTMLElement): void;
  90324. /**
  90325. * Asks the browser to exit fullscreen mode
  90326. */
  90327. static ExitFullscreen(): void;
  90328. /**
  90329. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90330. * @param url define the url we are trying
  90331. * @param element define the dom element where to configure the cors policy
  90332. */
  90333. static SetCorsBehavior(url: string | string[], element: {
  90334. crossOrigin: string | null;
  90335. }): void;
  90336. /**
  90337. * Removes unwanted characters from an url
  90338. * @param url defines the url to clean
  90339. * @returns the cleaned url
  90340. */
  90341. static CleanUrl(url: string): string;
  90342. /**
  90343. * Gets or sets a function used to pre-process url before using them to load assets
  90344. */
  90345. static PreprocessUrl: (url: string) => string;
  90346. /**
  90347. * Loads an image as an HTMLImageElement.
  90348. * @param input url string, ArrayBuffer, or Blob to load
  90349. * @param onLoad callback called when the image successfully loads
  90350. * @param onError callback called when the image fails to load
  90351. * @param offlineProvider offline provider for caching
  90352. * @returns the HTMLImageElement of the loaded image
  90353. */
  90354. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90355. /**
  90356. * Loads a file
  90357. * @param url url string, ArrayBuffer, or Blob to load
  90358. * @param onSuccess callback called when the file successfully loads
  90359. * @param onProgress callback called while file is loading (if the server supports this mode)
  90360. * @param offlineProvider defines the offline provider for caching
  90361. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90362. * @param onError callback called when the file fails to load
  90363. * @returns a file request object
  90364. */
  90365. 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;
  90366. /**
  90367. * Load a script (identified by an url). When the url returns, the
  90368. * content of this file is added into a new script element, attached to the DOM (body element)
  90369. * @param scriptUrl defines the url of the script to laod
  90370. * @param onSuccess defines the callback called when the script is loaded
  90371. * @param onError defines the callback to call if an error occurs
  90372. * @param scriptId defines the id of the script element
  90373. */
  90374. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90375. /**
  90376. * Load an asynchronous script (identified by an url). When the url returns, the
  90377. * content of this file is added into a new script element, attached to the DOM (body element)
  90378. * @param scriptUrl defines the url of the script to laod
  90379. * @param scriptId defines the id of the script element
  90380. * @returns a promise request object
  90381. */
  90382. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90383. /**
  90384. * Loads a file from a blob
  90385. * @param fileToLoad defines the blob to use
  90386. * @param callback defines the callback to call when data is loaded
  90387. * @param progressCallback defines the callback to call during loading process
  90388. * @returns a file request object
  90389. */
  90390. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90391. /**
  90392. * Loads a file
  90393. * @param fileToLoad defines the file to load
  90394. * @param callback defines the callback to call when data is loaded
  90395. * @param progressCallBack defines the callback to call during loading process
  90396. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90397. * @returns a file request object
  90398. */
  90399. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90400. /**
  90401. * Creates a data url from a given string content
  90402. * @param content defines the content to convert
  90403. * @returns the new data url link
  90404. */
  90405. static FileAsURL(content: string): string;
  90406. /**
  90407. * Format the given number to a specific decimal format
  90408. * @param value defines the number to format
  90409. * @param decimals defines the number of decimals to use
  90410. * @returns the formatted string
  90411. */
  90412. static Format(value: number, decimals?: number): string;
  90413. /**
  90414. * Checks if a given vector is inside a specific range
  90415. * @param v defines the vector to test
  90416. * @param min defines the minimum range
  90417. * @param max defines the maximum range
  90418. */
  90419. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90420. /**
  90421. * Tries to copy an object by duplicating every property
  90422. * @param source defines the source object
  90423. * @param destination defines the target object
  90424. * @param doNotCopyList defines a list of properties to avoid
  90425. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90426. */
  90427. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90428. /**
  90429. * Gets a boolean indicating if the given object has no own property
  90430. * @param obj defines the object to test
  90431. * @returns true if object has no own property
  90432. */
  90433. static IsEmpty(obj: any): boolean;
  90434. /**
  90435. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90436. * @param str Source string
  90437. * @param suffix Suffix to search for in the source string
  90438. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90439. */
  90440. static EndsWith(str: string, suffix: string): boolean;
  90441. /**
  90442. * Function used to register events at window level
  90443. * @param events defines the events to register
  90444. */
  90445. static RegisterTopRootEvents(events: {
  90446. name: string;
  90447. handler: Nullable<(e: FocusEvent) => any>;
  90448. }[]): void;
  90449. /**
  90450. * Function used to unregister events from window level
  90451. * @param events defines the events to unregister
  90452. */
  90453. static UnregisterTopRootEvents(events: {
  90454. name: string;
  90455. handler: Nullable<(e: FocusEvent) => any>;
  90456. }[]): void;
  90457. /**
  90458. * @ignore
  90459. */
  90460. static _ScreenshotCanvas: HTMLCanvasElement;
  90461. /**
  90462. * Dumps the current bound framebuffer
  90463. * @param width defines the rendering width
  90464. * @param height defines the rendering height
  90465. * @param engine defines the hosting engine
  90466. * @param successCallback defines the callback triggered once the data are available
  90467. * @param mimeType defines the mime type of the result
  90468. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90469. */
  90470. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90471. /**
  90472. * Converts the canvas data to blob.
  90473. * This acts as a polyfill for browsers not supporting the to blob function.
  90474. * @param canvas Defines the canvas to extract the data from
  90475. * @param successCallback Defines the callback triggered once the data are available
  90476. * @param mimeType Defines the mime type of the result
  90477. */
  90478. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90479. /**
  90480. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90481. * @param successCallback defines the callback triggered once the data are available
  90482. * @param mimeType defines the mime type of the result
  90483. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90484. */
  90485. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90486. /**
  90487. * Downloads a blob in the browser
  90488. * @param blob defines the blob to download
  90489. * @param fileName defines the name of the downloaded file
  90490. */
  90491. static Download(blob: Blob, fileName: string): void;
  90492. /**
  90493. * Captures a screenshot of the current rendering
  90494. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90495. * @param engine defines the rendering engine
  90496. * @param camera defines the source camera
  90497. * @param size This parameter can be set to a single number or to an object with the
  90498. * following (optional) properties: precision, width, height. If a single number is passed,
  90499. * it will be used for both width and height. If an object is passed, the screenshot size
  90500. * will be derived from the parameters. The precision property is a multiplier allowing
  90501. * rendering at a higher or lower resolution
  90502. * @param successCallback defines the callback receives a single parameter which contains the
  90503. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90504. * src parameter of an <img> to display it
  90505. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90506. * Check your browser for supported MIME types
  90507. */
  90508. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90509. /**
  90510. * Generates an image screenshot from the specified camera.
  90511. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90512. * @param engine The engine to use for rendering
  90513. * @param camera The camera to use for rendering
  90514. * @param size This parameter can be set to a single number or to an object with the
  90515. * following (optional) properties: precision, width, height. If a single number is passed,
  90516. * it will be used for both width and height. If an object is passed, the screenshot size
  90517. * will be derived from the parameters. The precision property is a multiplier allowing
  90518. * rendering at a higher or lower resolution
  90519. * @param successCallback The callback receives a single parameter which contains the
  90520. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90521. * src parameter of an <img> to display it
  90522. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90523. * Check your browser for supported MIME types
  90524. * @param samples Texture samples (default: 1)
  90525. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90526. * @param fileName A name for for the downloaded file.
  90527. */
  90528. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90529. /**
  90530. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90531. * Be aware Math.random() could cause collisions, but:
  90532. * "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"
  90533. * @returns a pseudo random id
  90534. */
  90535. static RandomId(): string;
  90536. /**
  90537. * Test if the given uri is a base64 string
  90538. * @param uri The uri to test
  90539. * @return True if the uri is a base64 string or false otherwise
  90540. */
  90541. static IsBase64(uri: string): boolean;
  90542. /**
  90543. * Decode the given base64 uri.
  90544. * @param uri The uri to decode
  90545. * @return The decoded base64 data.
  90546. */
  90547. static DecodeBase64(uri: string): ArrayBuffer;
  90548. /**
  90549. * Gets the absolute url.
  90550. * @param url the input url
  90551. * @return the absolute url
  90552. */
  90553. static GetAbsoluteUrl(url: string): string;
  90554. /**
  90555. * No log
  90556. */
  90557. static readonly NoneLogLevel: number;
  90558. /**
  90559. * Only message logs
  90560. */
  90561. static readonly MessageLogLevel: number;
  90562. /**
  90563. * Only warning logs
  90564. */
  90565. static readonly WarningLogLevel: number;
  90566. /**
  90567. * Only error logs
  90568. */
  90569. static readonly ErrorLogLevel: number;
  90570. /**
  90571. * All logs
  90572. */
  90573. static readonly AllLogLevel: number;
  90574. /**
  90575. * Gets a value indicating the number of loading errors
  90576. * @ignorenaming
  90577. */
  90578. static readonly errorsCount: number;
  90579. /**
  90580. * Callback called when a new log is added
  90581. */
  90582. static OnNewCacheEntry: (entry: string) => void;
  90583. /**
  90584. * Log a message to the console
  90585. * @param message defines the message to log
  90586. */
  90587. static Log(message: string): void;
  90588. /**
  90589. * Write a warning message to the console
  90590. * @param message defines the message to log
  90591. */
  90592. static Warn(message: string): void;
  90593. /**
  90594. * Write an error message to the console
  90595. * @param message defines the message to log
  90596. */
  90597. static Error(message: string): void;
  90598. /**
  90599. * Gets current log cache (list of logs)
  90600. */
  90601. static readonly LogCache: string;
  90602. /**
  90603. * Clears the log cache
  90604. */
  90605. static ClearLogCache(): void;
  90606. /**
  90607. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90608. */
  90609. static LogLevels: number;
  90610. /**
  90611. * Checks if the loaded document was accessed via `file:`-Protocol.
  90612. * @returns boolean
  90613. */
  90614. static IsFileURL(): boolean;
  90615. /**
  90616. * Checks if the window object exists
  90617. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90618. */
  90619. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90620. /**
  90621. * No performance log
  90622. */
  90623. static readonly PerformanceNoneLogLevel: number;
  90624. /**
  90625. * Use user marks to log performance
  90626. */
  90627. static readonly PerformanceUserMarkLogLevel: number;
  90628. /**
  90629. * Log performance to the console
  90630. */
  90631. static readonly PerformanceConsoleLogLevel: number;
  90632. private static _performance;
  90633. /**
  90634. * Sets the current performance log level
  90635. */
  90636. static PerformanceLogLevel: number;
  90637. private static _StartPerformanceCounterDisabled;
  90638. private static _EndPerformanceCounterDisabled;
  90639. private static _StartUserMark;
  90640. private static _EndUserMark;
  90641. private static _StartPerformanceConsole;
  90642. private static _EndPerformanceConsole;
  90643. /**
  90644. * Starts a performance counter
  90645. */
  90646. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90647. /**
  90648. * Ends a specific performance coutner
  90649. */
  90650. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90651. /**
  90652. * Gets either window.performance.now() if supported or Date.now() else
  90653. */
  90654. static readonly Now: number;
  90655. /**
  90656. * This method will return the name of the class used to create the instance of the given object.
  90657. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90658. * @param object the object to get the class name from
  90659. * @param isType defines if the object is actually a type
  90660. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90661. */
  90662. static GetClassName(object: any, isType?: boolean): string;
  90663. /**
  90664. * Gets the first element of an array satisfying a given predicate
  90665. * @param array defines the array to browse
  90666. * @param predicate defines the predicate to use
  90667. * @returns null if not found or the element
  90668. */
  90669. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90670. /**
  90671. * This method will return the name of the full name of the class, including its owning module (if any).
  90672. * 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).
  90673. * @param object the object to get the class name from
  90674. * @param isType defines if the object is actually a type
  90675. * @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.
  90676. * @ignorenaming
  90677. */
  90678. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90679. /**
  90680. * Returns a promise that resolves after the given amount of time.
  90681. * @param delay Number of milliseconds to delay
  90682. * @returns Promise that resolves after the given amount of time
  90683. */
  90684. static DelayAsync(delay: number): Promise<void>;
  90685. /**
  90686. * Gets the current gradient from an array of IValueGradient
  90687. * @param ratio defines the current ratio to get
  90688. * @param gradients defines the array of IValueGradient
  90689. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90690. */
  90691. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90692. }
  90693. /**
  90694. * This class is used to track a performance counter which is number based.
  90695. * The user has access to many properties which give statistics of different nature.
  90696. *
  90697. * The implementer can track two kinds of Performance Counter: time and count.
  90698. * 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.
  90699. * 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.
  90700. */
  90701. export class PerfCounter {
  90702. /**
  90703. * Gets or sets a global boolean to turn on and off all the counters
  90704. */
  90705. static Enabled: boolean;
  90706. /**
  90707. * Returns the smallest value ever
  90708. */
  90709. readonly min: number;
  90710. /**
  90711. * Returns the biggest value ever
  90712. */
  90713. readonly max: number;
  90714. /**
  90715. * Returns the average value since the performance counter is running
  90716. */
  90717. readonly average: number;
  90718. /**
  90719. * Returns the average value of the last second the counter was monitored
  90720. */
  90721. readonly lastSecAverage: number;
  90722. /**
  90723. * Returns the current value
  90724. */
  90725. readonly current: number;
  90726. /**
  90727. * Gets the accumulated total
  90728. */
  90729. readonly total: number;
  90730. /**
  90731. * Gets the total value count
  90732. */
  90733. readonly count: number;
  90734. /**
  90735. * Creates a new counter
  90736. */
  90737. constructor();
  90738. /**
  90739. * Call this method to start monitoring a new frame.
  90740. * 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.
  90741. */
  90742. fetchNewFrame(): void;
  90743. /**
  90744. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90745. * @param newCount the count value to add to the monitored count
  90746. * @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.
  90747. */
  90748. addCount(newCount: number, fetchResult: boolean): void;
  90749. /**
  90750. * Start monitoring this performance counter
  90751. */
  90752. beginMonitoring(): void;
  90753. /**
  90754. * Compute the time lapsed since the previous beginMonitoring() call.
  90755. * @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
  90756. */
  90757. endMonitoring(newFrame?: boolean): void;
  90758. private _fetchResult;
  90759. private _startMonitoringTime;
  90760. private _min;
  90761. private _max;
  90762. private _average;
  90763. private _current;
  90764. private _totalValueCount;
  90765. private _totalAccumulated;
  90766. private _lastSecAverage;
  90767. private _lastSecAccumulated;
  90768. private _lastSecTime;
  90769. private _lastSecValueCount;
  90770. }
  90771. /**
  90772. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90773. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90774. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90775. * @param name The name of the class, case should be preserved
  90776. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90777. */
  90778. export function className(name: string, module?: string): (target: Object) => void;
  90779. /**
  90780. * An implementation of a loop for asynchronous functions.
  90781. */
  90782. export class AsyncLoop {
  90783. /**
  90784. * Defines the number of iterations for the loop
  90785. */
  90786. iterations: number;
  90787. /**
  90788. * Defines the current index of the loop.
  90789. */
  90790. index: number;
  90791. private _done;
  90792. private _fn;
  90793. private _successCallback;
  90794. /**
  90795. * Constructor.
  90796. * @param iterations the number of iterations.
  90797. * @param func the function to run each iteration
  90798. * @param successCallback the callback that will be called upon succesful execution
  90799. * @param offset starting offset.
  90800. */
  90801. constructor(
  90802. /**
  90803. * Defines the number of iterations for the loop
  90804. */
  90805. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  90806. /**
  90807. * Execute the next iteration. Must be called after the last iteration was finished.
  90808. */
  90809. executeNext(): void;
  90810. /**
  90811. * Break the loop and run the success callback.
  90812. */
  90813. breakLoop(): void;
  90814. /**
  90815. * Create and run an async loop.
  90816. * @param iterations the number of iterations.
  90817. * @param fn the function to run each iteration
  90818. * @param successCallback the callback that will be called upon succesful execution
  90819. * @param offset starting offset.
  90820. * @returns the created async loop object
  90821. */
  90822. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  90823. /**
  90824. * A for-loop that will run a given number of iterations synchronous and the rest async.
  90825. * @param iterations total number of iterations
  90826. * @param syncedIterations number of synchronous iterations in each async iteration.
  90827. * @param fn the function to call each iteration.
  90828. * @param callback a success call back that will be called when iterating stops.
  90829. * @param breakFunction a break condition (optional)
  90830. * @param timeout timeout settings for the setTimeout function. default - 0.
  90831. * @returns the created async loop object
  90832. */
  90833. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  90834. }
  90835. }
  90836. declare module BABYLON {
  90837. /** @hidden */
  90838. export interface ICollisionCoordinator {
  90839. createCollider(): Collider;
  90840. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90841. init(scene: Scene): void;
  90842. }
  90843. /** @hidden */
  90844. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  90845. private _scene;
  90846. private _scaledPosition;
  90847. private _scaledVelocity;
  90848. private _finalPosition;
  90849. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  90850. createCollider(): Collider;
  90851. init(scene: Scene): void;
  90852. private _collideWithWorld;
  90853. }
  90854. }
  90855. declare module BABYLON {
  90856. /**
  90857. * This class defines the direct association between an animation and a target
  90858. */
  90859. export class TargetedAnimation {
  90860. /**
  90861. * Animation to perform
  90862. */
  90863. animation: Animation;
  90864. /**
  90865. * Target to animate
  90866. */
  90867. target: any;
  90868. }
  90869. /**
  90870. * Use this class to create coordinated animations on multiple targets
  90871. */
  90872. export class AnimationGroup implements IDisposable {
  90873. /** The name of the animation group */
  90874. name: string;
  90875. private _scene;
  90876. private _targetedAnimations;
  90877. private _animatables;
  90878. private _from;
  90879. private _to;
  90880. private _isStarted;
  90881. private _isPaused;
  90882. private _speedRatio;
  90883. /**
  90884. * Gets or sets the unique id of the node
  90885. */
  90886. uniqueId: number;
  90887. /**
  90888. * This observable will notify when one animation have ended
  90889. */
  90890. onAnimationEndObservable: Observable<TargetedAnimation>;
  90891. /**
  90892. * Observer raised when one animation loops
  90893. */
  90894. onAnimationLoopObservable: Observable<TargetedAnimation>;
  90895. /**
  90896. * This observable will notify when all animations have ended.
  90897. */
  90898. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  90899. /**
  90900. * This observable will notify when all animations have paused.
  90901. */
  90902. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  90903. /**
  90904. * This observable will notify when all animations are playing.
  90905. */
  90906. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  90907. /**
  90908. * Gets the first frame
  90909. */
  90910. readonly from: number;
  90911. /**
  90912. * Gets the last frame
  90913. */
  90914. readonly to: number;
  90915. /**
  90916. * Define if the animations are started
  90917. */
  90918. readonly isStarted: boolean;
  90919. /**
  90920. * Gets a value indicating that the current group is playing
  90921. */
  90922. readonly isPlaying: boolean;
  90923. /**
  90924. * Gets or sets the speed ratio to use for all animations
  90925. */
  90926. /**
  90927. * Gets or sets the speed ratio to use for all animations
  90928. */
  90929. speedRatio: number;
  90930. /**
  90931. * Gets the targeted animations for this animation group
  90932. */
  90933. readonly targetedAnimations: Array<TargetedAnimation>;
  90934. /**
  90935. * returning the list of animatables controlled by this animation group.
  90936. */
  90937. readonly animatables: Array<Animatable>;
  90938. /**
  90939. * Instantiates a new Animation Group.
  90940. * This helps managing several animations at once.
  90941. * @see http://doc.babylonjs.com/how_to/group
  90942. * @param name Defines the name of the group
  90943. * @param scene Defines the scene the group belongs to
  90944. */
  90945. constructor(
  90946. /** The name of the animation group */
  90947. name: string, scene?: Nullable<Scene>);
  90948. /**
  90949. * Add an animation (with its target) in the group
  90950. * @param animation defines the animation we want to add
  90951. * @param target defines the target of the animation
  90952. * @returns the TargetedAnimation object
  90953. */
  90954. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  90955. /**
  90956. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  90957. * It can add constant keys at begin or end
  90958. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  90959. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  90960. * @returns the animation group
  90961. */
  90962. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  90963. /**
  90964. * Start all animations on given targets
  90965. * @param loop defines if animations must loop
  90966. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  90967. * @param from defines the from key (optional)
  90968. * @param to defines the to key (optional)
  90969. * @returns the current animation group
  90970. */
  90971. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  90972. /**
  90973. * Pause all animations
  90974. * @returns the animation group
  90975. */
  90976. pause(): AnimationGroup;
  90977. /**
  90978. * Play all animations to initial state
  90979. * This function will start() the animations if they were not started or will restart() them if they were paused
  90980. * @param loop defines if animations must loop
  90981. * @returns the animation group
  90982. */
  90983. play(loop?: boolean): AnimationGroup;
  90984. /**
  90985. * Reset all animations to initial state
  90986. * @returns the animation group
  90987. */
  90988. reset(): AnimationGroup;
  90989. /**
  90990. * Restart animations from key 0
  90991. * @returns the animation group
  90992. */
  90993. restart(): AnimationGroup;
  90994. /**
  90995. * Stop all animations
  90996. * @returns the animation group
  90997. */
  90998. stop(): AnimationGroup;
  90999. /**
  91000. * Set animation weight for all animatables
  91001. * @param weight defines the weight to use
  91002. * @return the animationGroup
  91003. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91004. */
  91005. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91006. /**
  91007. * Synchronize and normalize all animatables with a source animatable
  91008. * @param root defines the root animatable to synchronize with
  91009. * @return the animationGroup
  91010. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91011. */
  91012. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91013. /**
  91014. * Goes to a specific frame in this animation group
  91015. * @param frame the frame number to go to
  91016. * @return the animationGroup
  91017. */
  91018. goToFrame(frame: number): AnimationGroup;
  91019. /**
  91020. * Dispose all associated resources
  91021. */
  91022. dispose(): void;
  91023. private _checkAnimationGroupEnded;
  91024. /**
  91025. * Clone the current animation group and returns a copy
  91026. * @param newName defines the name of the new group
  91027. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91028. * @returns the new aniamtion group
  91029. */
  91030. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91031. /**
  91032. * Returns a new AnimationGroup object parsed from the source provided.
  91033. * @param parsedAnimationGroup defines the source
  91034. * @param scene defines the scene that will receive the animationGroup
  91035. * @returns a new AnimationGroup
  91036. */
  91037. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91038. /**
  91039. * Returns the string "AnimationGroup"
  91040. * @returns "AnimationGroup"
  91041. */
  91042. getClassName(): string;
  91043. /**
  91044. * Creates a detailled string about the object
  91045. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91046. * @returns a string representing the object
  91047. */
  91048. toString(fullDetails?: boolean): string;
  91049. }
  91050. }
  91051. declare module BABYLON {
  91052. /**
  91053. * Define an interface for all classes that will hold resources
  91054. */
  91055. export interface IDisposable {
  91056. /**
  91057. * Releases all held resources
  91058. */
  91059. dispose(): void;
  91060. }
  91061. /** Interface defining initialization parameters for Scene class */
  91062. export interface SceneOptions {
  91063. /**
  91064. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91065. * It will improve performance when the number of geometries becomes important.
  91066. */
  91067. useGeometryUniqueIdsMap?: boolean;
  91068. /**
  91069. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91070. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91071. */
  91072. useMaterialMeshMap?: boolean;
  91073. /**
  91074. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91075. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91076. */
  91077. useClonedMeshhMap?: boolean;
  91078. }
  91079. /**
  91080. * Represents a scene to be rendered by the engine.
  91081. * @see http://doc.babylonjs.com/features/scene
  91082. */
  91083. export class Scene extends AbstractScene implements IAnimatable {
  91084. private static _uniqueIdCounter;
  91085. /** The fog is deactivated */
  91086. static readonly FOGMODE_NONE: number;
  91087. /** The fog density is following an exponential function */
  91088. static readonly FOGMODE_EXP: number;
  91089. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91090. static readonly FOGMODE_EXP2: number;
  91091. /** The fog density is following a linear function. */
  91092. static readonly FOGMODE_LINEAR: number;
  91093. /**
  91094. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91096. */
  91097. static MinDeltaTime: number;
  91098. /**
  91099. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91100. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91101. */
  91102. static MaxDeltaTime: number;
  91103. /**
  91104. * Factory used to create the default material.
  91105. * @param name The name of the material to create
  91106. * @param scene The scene to create the material for
  91107. * @returns The default material
  91108. */
  91109. static DefaultMaterialFactory(scene: Scene): Material;
  91110. /**
  91111. * Factory used to create the a collision coordinator.
  91112. * @returns The collision coordinator
  91113. */
  91114. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91115. /** @hidden */
  91116. readonly _isScene: boolean;
  91117. /**
  91118. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91119. */
  91120. autoClear: boolean;
  91121. /**
  91122. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91123. */
  91124. autoClearDepthAndStencil: boolean;
  91125. /**
  91126. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91127. */
  91128. clearColor: Color4;
  91129. /**
  91130. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91131. */
  91132. ambientColor: Color3;
  91133. /**
  91134. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91135. * It should only be one of the following (if not the default embedded one):
  91136. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91137. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91138. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91139. * The material properties need to be setup according to the type of texture in use.
  91140. */
  91141. environmentBRDFTexture: BaseTexture;
  91142. /** @hidden */
  91143. protected _environmentTexture: Nullable<BaseTexture>;
  91144. /**
  91145. * Texture used in all pbr material as the reflection texture.
  91146. * As in the majority of the scene they are the same (exception for multi room and so on),
  91147. * this is easier to reference from here than from all the materials.
  91148. */
  91149. /**
  91150. * Texture used in all pbr material as the reflection texture.
  91151. * As in the majority of the scene they are the same (exception for multi room and so on),
  91152. * this is easier to set here than in all the materials.
  91153. */
  91154. environmentTexture: Nullable<BaseTexture>;
  91155. /** @hidden */
  91156. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91157. /**
  91158. * Default image processing configuration used either in the rendering
  91159. * Forward main pass or through the imageProcessingPostProcess if present.
  91160. * As in the majority of the scene they are the same (exception for multi camera),
  91161. * this is easier to reference from here than from all the materials and post process.
  91162. *
  91163. * No setter as we it is a shared configuration, you can set the values instead.
  91164. */
  91165. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91166. private _forceWireframe;
  91167. /**
  91168. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91169. */
  91170. forceWireframe: boolean;
  91171. private _forcePointsCloud;
  91172. /**
  91173. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91174. */
  91175. forcePointsCloud: boolean;
  91176. /**
  91177. * Gets or sets the active clipplane 1
  91178. */
  91179. clipPlane: Nullable<Plane>;
  91180. /**
  91181. * Gets or sets the active clipplane 2
  91182. */
  91183. clipPlane2: Nullable<Plane>;
  91184. /**
  91185. * Gets or sets the active clipplane 3
  91186. */
  91187. clipPlane3: Nullable<Plane>;
  91188. /**
  91189. * Gets or sets the active clipplane 4
  91190. */
  91191. clipPlane4: Nullable<Plane>;
  91192. /**
  91193. * Gets or sets a boolean indicating if animations are enabled
  91194. */
  91195. animationsEnabled: boolean;
  91196. private _animationPropertiesOverride;
  91197. /**
  91198. * Gets or sets the animation properties override
  91199. */
  91200. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91201. /**
  91202. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91203. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91204. */
  91205. useConstantAnimationDeltaTime: boolean;
  91206. /**
  91207. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91208. * Please note that it requires to run a ray cast through the scene on every frame
  91209. */
  91210. constantlyUpdateMeshUnderPointer: boolean;
  91211. /**
  91212. * Defines the HTML cursor to use when hovering over interactive elements
  91213. */
  91214. hoverCursor: string;
  91215. /**
  91216. * Defines the HTML default cursor to use (empty by default)
  91217. */
  91218. defaultCursor: string;
  91219. /**
  91220. * This is used to call preventDefault() on pointer down
  91221. * in order to block unwanted artifacts like system double clicks
  91222. */
  91223. preventDefaultOnPointerDown: boolean;
  91224. /**
  91225. * This is used to call preventDefault() on pointer up
  91226. * in order to block unwanted artifacts like system double clicks
  91227. */
  91228. preventDefaultOnPointerUp: boolean;
  91229. /**
  91230. * Gets or sets user defined metadata
  91231. */
  91232. metadata: any;
  91233. /**
  91234. * For internal use only. Please do not use.
  91235. */
  91236. reservedDataStore: any;
  91237. /**
  91238. * Gets the name of the plugin used to load this scene (null by default)
  91239. */
  91240. loadingPluginName: string;
  91241. /**
  91242. * Use this array to add regular expressions used to disable offline support for specific urls
  91243. */
  91244. disableOfflineSupportExceptionRules: RegExp[];
  91245. /**
  91246. * An event triggered when the scene is disposed.
  91247. */
  91248. onDisposeObservable: Observable<Scene>;
  91249. private _onDisposeObserver;
  91250. /** Sets a function to be executed when this scene is disposed. */
  91251. onDispose: () => void;
  91252. /**
  91253. * An event triggered before rendering the scene (right after animations and physics)
  91254. */
  91255. onBeforeRenderObservable: Observable<Scene>;
  91256. private _onBeforeRenderObserver;
  91257. /** Sets a function to be executed before rendering this scene */
  91258. beforeRender: Nullable<() => void>;
  91259. /**
  91260. * An event triggered after rendering the scene
  91261. */
  91262. onAfterRenderObservable: Observable<Scene>;
  91263. private _onAfterRenderObserver;
  91264. /** Sets a function to be executed after rendering this scene */
  91265. afterRender: Nullable<() => void>;
  91266. /**
  91267. * An event triggered before animating the scene
  91268. */
  91269. onBeforeAnimationsObservable: Observable<Scene>;
  91270. /**
  91271. * An event triggered after animations processing
  91272. */
  91273. onAfterAnimationsObservable: Observable<Scene>;
  91274. /**
  91275. * An event triggered before draw calls are ready to be sent
  91276. */
  91277. onBeforeDrawPhaseObservable: Observable<Scene>;
  91278. /**
  91279. * An event triggered after draw calls have been sent
  91280. */
  91281. onAfterDrawPhaseObservable: Observable<Scene>;
  91282. /**
  91283. * An event triggered when the scene is ready
  91284. */
  91285. onReadyObservable: Observable<Scene>;
  91286. /**
  91287. * An event triggered before rendering a camera
  91288. */
  91289. onBeforeCameraRenderObservable: Observable<Camera>;
  91290. private _onBeforeCameraRenderObserver;
  91291. /** Sets a function to be executed before rendering a camera*/
  91292. beforeCameraRender: () => void;
  91293. /**
  91294. * An event triggered after rendering a camera
  91295. */
  91296. onAfterCameraRenderObservable: Observable<Camera>;
  91297. private _onAfterCameraRenderObserver;
  91298. /** Sets a function to be executed after rendering a camera*/
  91299. afterCameraRender: () => void;
  91300. /**
  91301. * An event triggered when active meshes evaluation is about to start
  91302. */
  91303. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91304. /**
  91305. * An event triggered when active meshes evaluation is done
  91306. */
  91307. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91308. /**
  91309. * An event triggered when particles rendering is about to start
  91310. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91311. */
  91312. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91313. /**
  91314. * An event triggered when particles rendering is done
  91315. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91316. */
  91317. onAfterParticlesRenderingObservable: Observable<Scene>;
  91318. /**
  91319. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91320. */
  91321. onDataLoadedObservable: Observable<Scene>;
  91322. /**
  91323. * An event triggered when a camera is created
  91324. */
  91325. onNewCameraAddedObservable: Observable<Camera>;
  91326. /**
  91327. * An event triggered when a camera is removed
  91328. */
  91329. onCameraRemovedObservable: Observable<Camera>;
  91330. /**
  91331. * An event triggered when a light is created
  91332. */
  91333. onNewLightAddedObservable: Observable<Light>;
  91334. /**
  91335. * An event triggered when a light is removed
  91336. */
  91337. onLightRemovedObservable: Observable<Light>;
  91338. /**
  91339. * An event triggered when a geometry is created
  91340. */
  91341. onNewGeometryAddedObservable: Observable<Geometry>;
  91342. /**
  91343. * An event triggered when a geometry is removed
  91344. */
  91345. onGeometryRemovedObservable: Observable<Geometry>;
  91346. /**
  91347. * An event triggered when a transform node is created
  91348. */
  91349. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91350. /**
  91351. * An event triggered when a transform node is removed
  91352. */
  91353. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91354. /**
  91355. * An event triggered when a mesh is created
  91356. */
  91357. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91358. /**
  91359. * An event triggered when a mesh is removed
  91360. */
  91361. onMeshRemovedObservable: Observable<AbstractMesh>;
  91362. /**
  91363. * An event triggered when a skeleton is created
  91364. */
  91365. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91366. /**
  91367. * An event triggered when a skeleton is removed
  91368. */
  91369. onSkeletonRemovedObservable: Observable<Skeleton>;
  91370. /**
  91371. * An event triggered when a material is created
  91372. */
  91373. onNewMaterialAddedObservable: Observable<Material>;
  91374. /**
  91375. * An event triggered when a material is removed
  91376. */
  91377. onMaterialRemovedObservable: Observable<Material>;
  91378. /**
  91379. * An event triggered when a texture is created
  91380. */
  91381. onNewTextureAddedObservable: Observable<BaseTexture>;
  91382. /**
  91383. * An event triggered when a texture is removed
  91384. */
  91385. onTextureRemovedObservable: Observable<BaseTexture>;
  91386. /**
  91387. * An event triggered when render targets are about to be rendered
  91388. * Can happen multiple times per frame.
  91389. */
  91390. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91391. /**
  91392. * An event triggered when render targets were rendered.
  91393. * Can happen multiple times per frame.
  91394. */
  91395. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91396. /**
  91397. * An event triggered before calculating deterministic simulation step
  91398. */
  91399. onBeforeStepObservable: Observable<Scene>;
  91400. /**
  91401. * An event triggered after calculating deterministic simulation step
  91402. */
  91403. onAfterStepObservable: Observable<Scene>;
  91404. /**
  91405. * An event triggered when the activeCamera property is updated
  91406. */
  91407. onActiveCameraChanged: Observable<Scene>;
  91408. /**
  91409. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91410. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91411. * 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)
  91412. */
  91413. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91414. /**
  91415. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91416. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91417. * 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)
  91418. */
  91419. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91420. /**
  91421. * This Observable will when a mesh has been imported into the scene.
  91422. */
  91423. onMeshImportedObservable: Observable<AbstractMesh>;
  91424. /**
  91425. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91426. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91427. */
  91428. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91429. /** @hidden */
  91430. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91431. /**
  91432. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91433. */
  91434. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91435. /**
  91436. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91437. */
  91438. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91439. /**
  91440. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91441. */
  91442. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91443. private _onPointerMove;
  91444. private _onPointerDown;
  91445. private _onPointerUp;
  91446. /** Callback called when a pointer move is detected */
  91447. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91448. /** Callback called when a pointer down is detected */
  91449. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91450. /** Callback called when a pointer up is detected */
  91451. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91452. /** Callback called when a pointer pick is detected */
  91453. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91454. /**
  91455. * 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).
  91456. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91457. */
  91458. onPrePointerObservable: Observable<PointerInfoPre>;
  91459. /**
  91460. * Observable event triggered each time an input event is received from the rendering canvas
  91461. */
  91462. onPointerObservable: Observable<PointerInfo>;
  91463. /**
  91464. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91465. */
  91466. readonly unTranslatedPointer: Vector2;
  91467. /** The distance in pixel that you have to move to prevent some events */
  91468. static DragMovementThreshold: number;
  91469. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91470. static LongPressDelay: number;
  91471. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91472. static DoubleClickDelay: number;
  91473. /** If you need to check double click without raising a single click at first click, enable this flag */
  91474. static ExclusiveDoubleClickMode: boolean;
  91475. private _initClickEvent;
  91476. private _initActionManager;
  91477. private _delayedSimpleClick;
  91478. private _delayedSimpleClickTimeout;
  91479. private _previousDelayedSimpleClickTimeout;
  91480. private _meshPickProceed;
  91481. private _previousButtonPressed;
  91482. private _currentPickResult;
  91483. private _previousPickResult;
  91484. private _totalPointersPressed;
  91485. private _doubleClickOccured;
  91486. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91487. cameraToUseForPointers: Nullable<Camera>;
  91488. private _pointerX;
  91489. private _pointerY;
  91490. private _unTranslatedPointerX;
  91491. private _unTranslatedPointerY;
  91492. private _startingPointerPosition;
  91493. private _previousStartingPointerPosition;
  91494. private _startingPointerTime;
  91495. private _previousStartingPointerTime;
  91496. private _pointerCaptures;
  91497. private _timeAccumulator;
  91498. private _currentStepId;
  91499. private _currentInternalStep;
  91500. /** @hidden */
  91501. _mirroredCameraPosition: Nullable<Vector3>;
  91502. /**
  91503. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91504. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91505. */
  91506. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91507. /**
  91508. * Observable event triggered each time an keyboard event is received from the hosting window
  91509. */
  91510. onKeyboardObservable: Observable<KeyboardInfo>;
  91511. private _onKeyDown;
  91512. private _onKeyUp;
  91513. private _onCanvasFocusObserver;
  91514. private _onCanvasBlurObserver;
  91515. private _useRightHandedSystem;
  91516. /**
  91517. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91518. */
  91519. useRightHandedSystem: boolean;
  91520. /**
  91521. * Sets the step Id used by deterministic lock step
  91522. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91523. * @param newStepId defines the step Id
  91524. */
  91525. setStepId(newStepId: number): void;
  91526. /**
  91527. * Gets the step Id used by deterministic lock step
  91528. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91529. * @returns the step Id
  91530. */
  91531. getStepId(): number;
  91532. /**
  91533. * Gets the internal step used by deterministic lock step
  91534. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91535. * @returns the internal step
  91536. */
  91537. getInternalStep(): number;
  91538. private _fogEnabled;
  91539. /**
  91540. * Gets or sets a boolean indicating if fog is enabled on this scene
  91541. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91542. * (Default is true)
  91543. */
  91544. fogEnabled: boolean;
  91545. private _fogMode;
  91546. /**
  91547. * Gets or sets the fog mode to use
  91548. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91549. * | mode | value |
  91550. * | --- | --- |
  91551. * | FOGMODE_NONE | 0 |
  91552. * | FOGMODE_EXP | 1 |
  91553. * | FOGMODE_EXP2 | 2 |
  91554. * | FOGMODE_LINEAR | 3 |
  91555. */
  91556. fogMode: number;
  91557. /**
  91558. * Gets or sets the fog color to use
  91559. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91560. * (Default is Color3(0.2, 0.2, 0.3))
  91561. */
  91562. fogColor: Color3;
  91563. /**
  91564. * Gets or sets the fog density to use
  91565. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91566. * (Default is 0.1)
  91567. */
  91568. fogDensity: number;
  91569. /**
  91570. * Gets or sets the fog start distance to use
  91571. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91572. * (Default is 0)
  91573. */
  91574. fogStart: number;
  91575. /**
  91576. * Gets or sets the fog end distance to use
  91577. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91578. * (Default is 1000)
  91579. */
  91580. fogEnd: number;
  91581. private _shadowsEnabled;
  91582. /**
  91583. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91584. */
  91585. shadowsEnabled: boolean;
  91586. private _lightsEnabled;
  91587. /**
  91588. * Gets or sets a boolean indicating if lights are enabled on this scene
  91589. */
  91590. lightsEnabled: boolean;
  91591. /** All of the active cameras added to this scene. */
  91592. activeCameras: Camera[];
  91593. /** @hidden */
  91594. _activeCamera: Nullable<Camera>;
  91595. /** Gets or sets the current active camera */
  91596. activeCamera: Nullable<Camera>;
  91597. private _defaultMaterial;
  91598. /** The default material used on meshes when no material is affected */
  91599. /** The default material used on meshes when no material is affected */
  91600. defaultMaterial: Material;
  91601. private _texturesEnabled;
  91602. /**
  91603. * Gets or sets a boolean indicating if textures are enabled on this scene
  91604. */
  91605. texturesEnabled: boolean;
  91606. /**
  91607. * Gets or sets a boolean indicating if particles are enabled on this scene
  91608. */
  91609. particlesEnabled: boolean;
  91610. /**
  91611. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91612. */
  91613. spritesEnabled: boolean;
  91614. private _skeletonsEnabled;
  91615. /**
  91616. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91617. */
  91618. skeletonsEnabled: boolean;
  91619. /**
  91620. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91621. */
  91622. lensFlaresEnabled: boolean;
  91623. /**
  91624. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91625. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91626. */
  91627. collisionsEnabled: boolean;
  91628. private _collisionCoordinator;
  91629. /** @hidden */
  91630. readonly collisionCoordinator: ICollisionCoordinator;
  91631. /**
  91632. * Defines the gravity applied to this scene (used only for collisions)
  91633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91634. */
  91635. gravity: Vector3;
  91636. /**
  91637. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91638. */
  91639. postProcessesEnabled: boolean;
  91640. /**
  91641. * The list of postprocesses added to the scene
  91642. */
  91643. postProcesses: PostProcess[];
  91644. /**
  91645. * Gets the current postprocess manager
  91646. */
  91647. postProcessManager: PostProcessManager;
  91648. /**
  91649. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91650. */
  91651. renderTargetsEnabled: boolean;
  91652. /**
  91653. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91654. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91655. */
  91656. dumpNextRenderTargets: boolean;
  91657. /**
  91658. * The list of user defined render targets added to the scene
  91659. */
  91660. customRenderTargets: RenderTargetTexture[];
  91661. /**
  91662. * Defines if texture loading must be delayed
  91663. * If true, textures will only be loaded when they need to be rendered
  91664. */
  91665. useDelayedTextureLoading: boolean;
  91666. /**
  91667. * Gets the list of meshes imported to the scene through SceneLoader
  91668. */
  91669. importedMeshesFiles: String[];
  91670. /**
  91671. * Gets or sets a boolean indicating if probes are enabled on this scene
  91672. */
  91673. probesEnabled: boolean;
  91674. /**
  91675. * Gets or sets the current offline provider to use to store scene data
  91676. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91677. */
  91678. offlineProvider: IOfflineProvider;
  91679. /**
  91680. * Gets or sets the action manager associated with the scene
  91681. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91682. */
  91683. actionManager: AbstractActionManager;
  91684. private _meshesForIntersections;
  91685. /**
  91686. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91687. */
  91688. proceduralTexturesEnabled: boolean;
  91689. private _engine;
  91690. private _totalVertices;
  91691. /** @hidden */
  91692. _activeIndices: PerfCounter;
  91693. /** @hidden */
  91694. _activeParticles: PerfCounter;
  91695. /** @hidden */
  91696. _activeBones: PerfCounter;
  91697. private _animationRatio;
  91698. /** @hidden */
  91699. _animationTimeLast: number;
  91700. /** @hidden */
  91701. _animationTime: number;
  91702. /**
  91703. * Gets or sets a general scale for animation speed
  91704. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91705. */
  91706. animationTimeScale: number;
  91707. /** @hidden */
  91708. _cachedMaterial: Nullable<Material>;
  91709. /** @hidden */
  91710. _cachedEffect: Nullable<Effect>;
  91711. /** @hidden */
  91712. _cachedVisibility: Nullable<number>;
  91713. private _renderId;
  91714. private _frameId;
  91715. private _executeWhenReadyTimeoutId;
  91716. private _intermediateRendering;
  91717. private _viewUpdateFlag;
  91718. private _projectionUpdateFlag;
  91719. /** @hidden */
  91720. _toBeDisposed: Nullable<IDisposable>[];
  91721. private _activeRequests;
  91722. /** @hidden */
  91723. _pendingData: any[];
  91724. private _isDisposed;
  91725. /**
  91726. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91727. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91728. */
  91729. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91730. private _activeMeshes;
  91731. private _processedMaterials;
  91732. private _renderTargets;
  91733. /** @hidden */
  91734. _activeParticleSystems: SmartArray<IParticleSystem>;
  91735. private _activeSkeletons;
  91736. private _softwareSkinnedMeshes;
  91737. private _renderingManager;
  91738. /** @hidden */
  91739. _activeAnimatables: Animatable[];
  91740. private _transformMatrix;
  91741. private _sceneUbo;
  91742. /** @hidden */
  91743. _viewMatrix: Matrix;
  91744. private _projectionMatrix;
  91745. private _wheelEventName;
  91746. /** @hidden */
  91747. _forcedViewPosition: Nullable<Vector3>;
  91748. /** @hidden */
  91749. _frustumPlanes: Plane[];
  91750. /**
  91751. * Gets the list of frustum planes (built from the active camera)
  91752. */
  91753. readonly frustumPlanes: Plane[];
  91754. /**
  91755. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91756. * This is useful if there are more lights that the maximum simulteanous authorized
  91757. */
  91758. requireLightSorting: boolean;
  91759. /** @hidden */
  91760. readonly useMaterialMeshMap: boolean;
  91761. /** @hidden */
  91762. readonly useClonedMeshhMap: boolean;
  91763. private _pointerOverMesh;
  91764. private _pickedDownMesh;
  91765. private _pickedUpMesh;
  91766. private _externalData;
  91767. private _uid;
  91768. /**
  91769. * @hidden
  91770. * Backing store of defined scene components.
  91771. */
  91772. _components: ISceneComponent[];
  91773. /**
  91774. * @hidden
  91775. * Backing store of defined scene components.
  91776. */
  91777. _serializableComponents: ISceneSerializableComponent[];
  91778. /**
  91779. * List of components to register on the next registration step.
  91780. */
  91781. private _transientComponents;
  91782. /**
  91783. * Registers the transient components if needed.
  91784. */
  91785. private _registerTransientComponents;
  91786. /**
  91787. * @hidden
  91788. * Add a component to the scene.
  91789. * Note that the ccomponent could be registered on th next frame if this is called after
  91790. * the register component stage.
  91791. * @param component Defines the component to add to the scene
  91792. */
  91793. _addComponent(component: ISceneComponent): void;
  91794. /**
  91795. * @hidden
  91796. * Gets a component from the scene.
  91797. * @param name defines the name of the component to retrieve
  91798. * @returns the component or null if not present
  91799. */
  91800. _getComponent(name: string): Nullable<ISceneComponent>;
  91801. /**
  91802. * @hidden
  91803. * Defines the actions happening before camera updates.
  91804. */
  91805. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  91806. /**
  91807. * @hidden
  91808. * Defines the actions happening before clear the canvas.
  91809. */
  91810. _beforeClearStage: Stage<SimpleStageAction>;
  91811. /**
  91812. * @hidden
  91813. * Defines the actions when collecting render targets for the frame.
  91814. */
  91815. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91816. /**
  91817. * @hidden
  91818. * Defines the actions happening for one camera in the frame.
  91819. */
  91820. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  91821. /**
  91822. * @hidden
  91823. * Defines the actions happening during the per mesh ready checks.
  91824. */
  91825. _isReadyForMeshStage: Stage<MeshStageAction>;
  91826. /**
  91827. * @hidden
  91828. * Defines the actions happening before evaluate active mesh checks.
  91829. */
  91830. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  91831. /**
  91832. * @hidden
  91833. * Defines the actions happening during the evaluate sub mesh checks.
  91834. */
  91835. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  91836. /**
  91837. * @hidden
  91838. * Defines the actions happening during the active mesh stage.
  91839. */
  91840. _activeMeshStage: Stage<ActiveMeshStageAction>;
  91841. /**
  91842. * @hidden
  91843. * Defines the actions happening during the per camera render target step.
  91844. */
  91845. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  91846. /**
  91847. * @hidden
  91848. * Defines the actions happening just before the active camera is drawing.
  91849. */
  91850. _beforeCameraDrawStage: Stage<CameraStageAction>;
  91851. /**
  91852. * @hidden
  91853. * Defines the actions happening just before a render target is drawing.
  91854. */
  91855. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91856. /**
  91857. * @hidden
  91858. * Defines the actions happening just before a rendering group is drawing.
  91859. */
  91860. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91861. /**
  91862. * @hidden
  91863. * Defines the actions happening just before a mesh is drawing.
  91864. */
  91865. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91866. /**
  91867. * @hidden
  91868. * Defines the actions happening just after a mesh has been drawn.
  91869. */
  91870. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  91871. /**
  91872. * @hidden
  91873. * Defines the actions happening just after a rendering group has been drawn.
  91874. */
  91875. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  91876. /**
  91877. * @hidden
  91878. * Defines the actions happening just after the active camera has been drawn.
  91879. */
  91880. _afterCameraDrawStage: Stage<CameraStageAction>;
  91881. /**
  91882. * @hidden
  91883. * Defines the actions happening just after a render target has been drawn.
  91884. */
  91885. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  91886. /**
  91887. * @hidden
  91888. * Defines the actions happening just after rendering all cameras and computing intersections.
  91889. */
  91890. _afterRenderStage: Stage<SimpleStageAction>;
  91891. /**
  91892. * @hidden
  91893. * Defines the actions happening when a pointer move event happens.
  91894. */
  91895. _pointerMoveStage: Stage<PointerMoveStageAction>;
  91896. /**
  91897. * @hidden
  91898. * Defines the actions happening when a pointer down event happens.
  91899. */
  91900. _pointerDownStage: Stage<PointerUpDownStageAction>;
  91901. /**
  91902. * @hidden
  91903. * Defines the actions happening when a pointer up event happens.
  91904. */
  91905. _pointerUpStage: Stage<PointerUpDownStageAction>;
  91906. /**
  91907. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  91908. */
  91909. private geometriesByUniqueId;
  91910. /**
  91911. * Creates a new Scene
  91912. * @param engine defines the engine to use to render this scene
  91913. * @param options defines the scene options
  91914. */
  91915. constructor(engine: Engine, options?: SceneOptions);
  91916. /**
  91917. * Gets a string idenfifying the name of the class
  91918. * @returns "Scene" string
  91919. */
  91920. getClassName(): string;
  91921. private _defaultMeshCandidates;
  91922. /**
  91923. * @hidden
  91924. */
  91925. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  91926. private _defaultSubMeshCandidates;
  91927. /**
  91928. * @hidden
  91929. */
  91930. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  91931. /**
  91932. * Sets the default candidate providers for the scene.
  91933. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  91934. * and getCollidingSubMeshCandidates to their default function
  91935. */
  91936. setDefaultCandidateProviders(): void;
  91937. /**
  91938. * Gets the mesh that is currently under the pointer
  91939. */
  91940. readonly meshUnderPointer: Nullable<AbstractMesh>;
  91941. /**
  91942. * Gets or sets the current on-screen X position of the pointer
  91943. */
  91944. pointerX: number;
  91945. /**
  91946. * Gets or sets the current on-screen Y position of the pointer
  91947. */
  91948. pointerY: number;
  91949. /**
  91950. * Gets the cached material (ie. the latest rendered one)
  91951. * @returns the cached material
  91952. */
  91953. getCachedMaterial(): Nullable<Material>;
  91954. /**
  91955. * Gets the cached effect (ie. the latest rendered one)
  91956. * @returns the cached effect
  91957. */
  91958. getCachedEffect(): Nullable<Effect>;
  91959. /**
  91960. * Gets the cached visibility state (ie. the latest rendered one)
  91961. * @returns the cached visibility state
  91962. */
  91963. getCachedVisibility(): Nullable<number>;
  91964. /**
  91965. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  91966. * @param material defines the current material
  91967. * @param effect defines the current effect
  91968. * @param visibility defines the current visibility state
  91969. * @returns true if one parameter is not cached
  91970. */
  91971. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  91972. /**
  91973. * Gets the engine associated with the scene
  91974. * @returns an Engine
  91975. */
  91976. getEngine(): Engine;
  91977. /**
  91978. * Gets the total number of vertices rendered per frame
  91979. * @returns the total number of vertices rendered per frame
  91980. */
  91981. getTotalVertices(): number;
  91982. /**
  91983. * Gets the performance counter for total vertices
  91984. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91985. */
  91986. readonly totalVerticesPerfCounter: PerfCounter;
  91987. /**
  91988. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  91989. * @returns the total number of active indices rendered per frame
  91990. */
  91991. getActiveIndices(): number;
  91992. /**
  91993. * Gets the performance counter for active indices
  91994. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  91995. */
  91996. readonly totalActiveIndicesPerfCounter: PerfCounter;
  91997. /**
  91998. * Gets the total number of active particles rendered per frame
  91999. * @returns the total number of active particles rendered per frame
  92000. */
  92001. getActiveParticles(): number;
  92002. /**
  92003. * Gets the performance counter for active particles
  92004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92005. */
  92006. readonly activeParticlesPerfCounter: PerfCounter;
  92007. /**
  92008. * Gets the total number of active bones rendered per frame
  92009. * @returns the total number of active bones rendered per frame
  92010. */
  92011. getActiveBones(): number;
  92012. /**
  92013. * Gets the performance counter for active bones
  92014. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92015. */
  92016. readonly activeBonesPerfCounter: PerfCounter;
  92017. /**
  92018. * Gets the array of active meshes
  92019. * @returns an array of AbstractMesh
  92020. */
  92021. getActiveMeshes(): SmartArray<AbstractMesh>;
  92022. /**
  92023. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92024. * @returns a number
  92025. */
  92026. getAnimationRatio(): number;
  92027. /**
  92028. * Gets an unique Id for the current render phase
  92029. * @returns a number
  92030. */
  92031. getRenderId(): number;
  92032. /**
  92033. * Gets an unique Id for the current frame
  92034. * @returns a number
  92035. */
  92036. getFrameId(): number;
  92037. /** Call this function if you want to manually increment the render Id*/
  92038. incrementRenderId(): void;
  92039. private _updatePointerPosition;
  92040. private _createUbo;
  92041. private _setRayOnPointerInfo;
  92042. /**
  92043. * Use this method to simulate a pointer move on a mesh
  92044. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92045. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92046. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92047. * @returns the current scene
  92048. */
  92049. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92050. private _processPointerMove;
  92051. private _checkPrePointerObservable;
  92052. /**
  92053. * Use this method to simulate a pointer down on a mesh
  92054. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92055. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92056. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92057. * @returns the current scene
  92058. */
  92059. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92060. private _processPointerDown;
  92061. /**
  92062. * Use this method to simulate a pointer up on a mesh
  92063. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92064. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92065. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92066. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92067. * @returns the current scene
  92068. */
  92069. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92070. private _processPointerUp;
  92071. /**
  92072. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92073. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92074. * @returns true if the pointer was captured
  92075. */
  92076. isPointerCaptured(pointerId?: number): boolean;
  92077. /** @hidden */
  92078. _isPointerSwiping(): boolean;
  92079. /**
  92080. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92081. * @param attachUp defines if you want to attach events to pointerup
  92082. * @param attachDown defines if you want to attach events to pointerdown
  92083. * @param attachMove defines if you want to attach events to pointermove
  92084. */
  92085. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92086. /** Detaches all event handlers*/
  92087. detachControl(): void;
  92088. /**
  92089. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92090. * Delay loaded resources are not taking in account
  92091. * @return true if all required resources are ready
  92092. */
  92093. isReady(): boolean;
  92094. /** Resets all cached information relative to material (including effect and visibility) */
  92095. resetCachedMaterial(): void;
  92096. /**
  92097. * Registers a function to be called before every frame render
  92098. * @param func defines the function to register
  92099. */
  92100. registerBeforeRender(func: () => void): void;
  92101. /**
  92102. * Unregisters a function called before every frame render
  92103. * @param func defines the function to unregister
  92104. */
  92105. unregisterBeforeRender(func: () => void): void;
  92106. /**
  92107. * Registers a function to be called after every frame render
  92108. * @param func defines the function to register
  92109. */
  92110. registerAfterRender(func: () => void): void;
  92111. /**
  92112. * Unregisters a function called after every frame render
  92113. * @param func defines the function to unregister
  92114. */
  92115. unregisterAfterRender(func: () => void): void;
  92116. private _executeOnceBeforeRender;
  92117. /**
  92118. * The provided function will run before render once and will be disposed afterwards.
  92119. * A timeout delay can be provided so that the function will be executed in N ms.
  92120. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92121. * @param func The function to be executed.
  92122. * @param timeout optional delay in ms
  92123. */
  92124. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92125. /** @hidden */
  92126. _addPendingData(data: any): void;
  92127. /** @hidden */
  92128. _removePendingData(data: any): void;
  92129. /**
  92130. * Returns the number of items waiting to be loaded
  92131. * @returns the number of items waiting to be loaded
  92132. */
  92133. getWaitingItemsCount(): number;
  92134. /**
  92135. * Returns a boolean indicating if the scene is still loading data
  92136. */
  92137. readonly isLoading: boolean;
  92138. /**
  92139. * Registers a function to be executed when the scene is ready
  92140. * @param {Function} func - the function to be executed
  92141. */
  92142. executeWhenReady(func: () => void): void;
  92143. /**
  92144. * Returns a promise that resolves when the scene is ready
  92145. * @returns A promise that resolves when the scene is ready
  92146. */
  92147. whenReadyAsync(): Promise<void>;
  92148. /** @hidden */
  92149. _checkIsReady(): void;
  92150. /**
  92151. * Gets all animatable attached to the scene
  92152. */
  92153. readonly animatables: Animatable[];
  92154. /**
  92155. * Resets the last animation time frame.
  92156. * Useful to override when animations start running when loading a scene for the first time.
  92157. */
  92158. resetLastAnimationTimeFrame(): void;
  92159. /**
  92160. * Gets the current view matrix
  92161. * @returns a Matrix
  92162. */
  92163. getViewMatrix(): Matrix;
  92164. /**
  92165. * Gets the current projection matrix
  92166. * @returns a Matrix
  92167. */
  92168. getProjectionMatrix(): Matrix;
  92169. /**
  92170. * Gets the current transform matrix
  92171. * @returns a Matrix made of View * Projection
  92172. */
  92173. getTransformMatrix(): Matrix;
  92174. /**
  92175. * Sets the current transform matrix
  92176. * @param viewL defines the View matrix to use
  92177. * @param projectionL defines the Projection matrix to use
  92178. * @param viewR defines the right View matrix to use (if provided)
  92179. * @param projectionR defines the right Projection matrix to use (if provided)
  92180. */
  92181. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92182. /**
  92183. * Gets the uniform buffer used to store scene data
  92184. * @returns a UniformBuffer
  92185. */
  92186. getSceneUniformBuffer(): UniformBuffer;
  92187. /**
  92188. * Gets an unique (relatively to the current scene) Id
  92189. * @returns an unique number for the scene
  92190. */
  92191. getUniqueId(): number;
  92192. /**
  92193. * Add a mesh to the list of scene's meshes
  92194. * @param newMesh defines the mesh to add
  92195. * @param recursive if all child meshes should also be added to the scene
  92196. */
  92197. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92198. /**
  92199. * Remove a mesh for the list of scene's meshes
  92200. * @param toRemove defines the mesh to remove
  92201. * @param recursive if all child meshes should also be removed from the scene
  92202. * @returns the index where the mesh was in the mesh list
  92203. */
  92204. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92205. /**
  92206. * Add a transform node to the list of scene's transform nodes
  92207. * @param newTransformNode defines the transform node to add
  92208. */
  92209. addTransformNode(newTransformNode: TransformNode): void;
  92210. /**
  92211. * Remove a transform node for the list of scene's transform nodes
  92212. * @param toRemove defines the transform node to remove
  92213. * @returns the index where the transform node was in the transform node list
  92214. */
  92215. removeTransformNode(toRemove: TransformNode): number;
  92216. /**
  92217. * Remove a skeleton for the list of scene's skeletons
  92218. * @param toRemove defines the skeleton to remove
  92219. * @returns the index where the skeleton was in the skeleton list
  92220. */
  92221. removeSkeleton(toRemove: Skeleton): number;
  92222. /**
  92223. * Remove a morph target for the list of scene's morph targets
  92224. * @param toRemove defines the morph target to remove
  92225. * @returns the index where the morph target was in the morph target list
  92226. */
  92227. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92228. /**
  92229. * Remove a light for the list of scene's lights
  92230. * @param toRemove defines the light to remove
  92231. * @returns the index where the light was in the light list
  92232. */
  92233. removeLight(toRemove: Light): number;
  92234. /**
  92235. * Remove a camera for the list of scene's cameras
  92236. * @param toRemove defines the camera to remove
  92237. * @returns the index where the camera was in the camera list
  92238. */
  92239. removeCamera(toRemove: Camera): number;
  92240. /**
  92241. * Remove a particle system for the list of scene's particle systems
  92242. * @param toRemove defines the particle system to remove
  92243. * @returns the index where the particle system was in the particle system list
  92244. */
  92245. removeParticleSystem(toRemove: IParticleSystem): number;
  92246. /**
  92247. * Remove a animation for the list of scene's animations
  92248. * @param toRemove defines the animation to remove
  92249. * @returns the index where the animation was in the animation list
  92250. */
  92251. removeAnimation(toRemove: Animation): number;
  92252. /**
  92253. * Removes the given animation group from this scene.
  92254. * @param toRemove The animation group to remove
  92255. * @returns The index of the removed animation group
  92256. */
  92257. removeAnimationGroup(toRemove: AnimationGroup): number;
  92258. /**
  92259. * Removes the given multi-material from this scene.
  92260. * @param toRemove The multi-material to remove
  92261. * @returns The index of the removed multi-material
  92262. */
  92263. removeMultiMaterial(toRemove: MultiMaterial): number;
  92264. /**
  92265. * Removes the given material from this scene.
  92266. * @param toRemove The material to remove
  92267. * @returns The index of the removed material
  92268. */
  92269. removeMaterial(toRemove: Material): number;
  92270. /**
  92271. * Removes the given action manager from this scene.
  92272. * @param toRemove The action manager to remove
  92273. * @returns The index of the removed action manager
  92274. */
  92275. removeActionManager(toRemove: AbstractActionManager): number;
  92276. /**
  92277. * Removes the given texture from this scene.
  92278. * @param toRemove The texture to remove
  92279. * @returns The index of the removed texture
  92280. */
  92281. removeTexture(toRemove: BaseTexture): number;
  92282. /**
  92283. * Adds the given light to this scene
  92284. * @param newLight The light to add
  92285. */
  92286. addLight(newLight: Light): void;
  92287. /**
  92288. * Sorts the list list based on light priorities
  92289. */
  92290. sortLightsByPriority(): void;
  92291. /**
  92292. * Adds the given camera to this scene
  92293. * @param newCamera The camera to add
  92294. */
  92295. addCamera(newCamera: Camera): void;
  92296. /**
  92297. * Adds the given skeleton to this scene
  92298. * @param newSkeleton The skeleton to add
  92299. */
  92300. addSkeleton(newSkeleton: Skeleton): void;
  92301. /**
  92302. * Adds the given particle system to this scene
  92303. * @param newParticleSystem The particle system to add
  92304. */
  92305. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92306. /**
  92307. * Adds the given animation to this scene
  92308. * @param newAnimation The animation to add
  92309. */
  92310. addAnimation(newAnimation: Animation): void;
  92311. /**
  92312. * Adds the given animation group to this scene.
  92313. * @param newAnimationGroup The animation group to add
  92314. */
  92315. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92316. /**
  92317. * Adds the given multi-material to this scene
  92318. * @param newMultiMaterial The multi-material to add
  92319. */
  92320. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92321. /**
  92322. * Adds the given material to this scene
  92323. * @param newMaterial The material to add
  92324. */
  92325. addMaterial(newMaterial: Material): void;
  92326. /**
  92327. * Adds the given morph target to this scene
  92328. * @param newMorphTargetManager The morph target to add
  92329. */
  92330. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92331. /**
  92332. * Adds the given geometry to this scene
  92333. * @param newGeometry The geometry to add
  92334. */
  92335. addGeometry(newGeometry: Geometry): void;
  92336. /**
  92337. * Adds the given action manager to this scene
  92338. * @param newActionManager The action manager to add
  92339. */
  92340. addActionManager(newActionManager: AbstractActionManager): void;
  92341. /**
  92342. * Adds the given texture to this scene.
  92343. * @param newTexture The texture to add
  92344. */
  92345. addTexture(newTexture: BaseTexture): void;
  92346. /**
  92347. * Switch active camera
  92348. * @param newCamera defines the new active camera
  92349. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92350. */
  92351. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92352. /**
  92353. * sets the active camera of the scene using its ID
  92354. * @param id defines the camera's ID
  92355. * @return the new active camera or null if none found.
  92356. */
  92357. setActiveCameraByID(id: string): Nullable<Camera>;
  92358. /**
  92359. * sets the active camera of the scene using its name
  92360. * @param name defines the camera's name
  92361. * @returns the new active camera or null if none found.
  92362. */
  92363. setActiveCameraByName(name: string): Nullable<Camera>;
  92364. /**
  92365. * get an animation group using its name
  92366. * @param name defines the material's name
  92367. * @return the animation group or null if none found.
  92368. */
  92369. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92370. /**
  92371. * Get a material using its unique id
  92372. * @param uniqueId defines the material's unique id
  92373. * @return the material or null if none found.
  92374. */
  92375. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92376. /**
  92377. * get a material using its id
  92378. * @param id defines the material's ID
  92379. * @return the material or null if none found.
  92380. */
  92381. getMaterialByID(id: string): Nullable<Material>;
  92382. /**
  92383. * Gets a material using its name
  92384. * @param name defines the material's name
  92385. * @return the material or null if none found.
  92386. */
  92387. getMaterialByName(name: string): Nullable<Material>;
  92388. /**
  92389. * Gets a camera using its id
  92390. * @param id defines the id to look for
  92391. * @returns the camera or null if not found
  92392. */
  92393. getCameraByID(id: string): Nullable<Camera>;
  92394. /**
  92395. * Gets a camera using its unique id
  92396. * @param uniqueId defines the unique id to look for
  92397. * @returns the camera or null if not found
  92398. */
  92399. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92400. /**
  92401. * Gets a camera using its name
  92402. * @param name defines the camera's name
  92403. * @return the camera or null if none found.
  92404. */
  92405. getCameraByName(name: string): Nullable<Camera>;
  92406. /**
  92407. * Gets a bone using its id
  92408. * @param id defines the bone's id
  92409. * @return the bone or null if not found
  92410. */
  92411. getBoneByID(id: string): Nullable<Bone>;
  92412. /**
  92413. * Gets a bone using its id
  92414. * @param name defines the bone's name
  92415. * @return the bone or null if not found
  92416. */
  92417. getBoneByName(name: string): Nullable<Bone>;
  92418. /**
  92419. * Gets a light node using its name
  92420. * @param name defines the the light's name
  92421. * @return the light or null if none found.
  92422. */
  92423. getLightByName(name: string): Nullable<Light>;
  92424. /**
  92425. * Gets a light node using its id
  92426. * @param id defines the light's id
  92427. * @return the light or null if none found.
  92428. */
  92429. getLightByID(id: string): Nullable<Light>;
  92430. /**
  92431. * Gets a light node using its scene-generated unique ID
  92432. * @param uniqueId defines the light's unique id
  92433. * @return the light or null if none found.
  92434. */
  92435. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92436. /**
  92437. * Gets a particle system by id
  92438. * @param id defines the particle system id
  92439. * @return the corresponding system or null if none found
  92440. */
  92441. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92442. /**
  92443. * Gets a geometry using its ID
  92444. * @param id defines the geometry's id
  92445. * @return the geometry or null if none found.
  92446. */
  92447. getGeometryByID(id: string): Nullable<Geometry>;
  92448. private _getGeometryByUniqueID;
  92449. /**
  92450. * Add a new geometry to this scene
  92451. * @param geometry defines the geometry to be added to the scene.
  92452. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92453. * @return a boolean defining if the geometry was added or not
  92454. */
  92455. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92456. /**
  92457. * Removes an existing geometry
  92458. * @param geometry defines the geometry to be removed from the scene
  92459. * @return a boolean defining if the geometry was removed or not
  92460. */
  92461. removeGeometry(geometry: Geometry): boolean;
  92462. /**
  92463. * Gets the list of geometries attached to the scene
  92464. * @returns an array of Geometry
  92465. */
  92466. getGeometries(): Geometry[];
  92467. /**
  92468. * Gets the first added mesh found of a given ID
  92469. * @param id defines the id to search for
  92470. * @return the mesh found or null if not found at all
  92471. */
  92472. getMeshByID(id: string): Nullable<AbstractMesh>;
  92473. /**
  92474. * Gets a list of meshes using their id
  92475. * @param id defines the id to search for
  92476. * @returns a list of meshes
  92477. */
  92478. getMeshesByID(id: string): Array<AbstractMesh>;
  92479. /**
  92480. * Gets the first added transform node found of a given ID
  92481. * @param id defines the id to search for
  92482. * @return the found transform node or null if not found at all.
  92483. */
  92484. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92485. /**
  92486. * Gets a transform node with its auto-generated unique id
  92487. * @param uniqueId efines the unique id to search for
  92488. * @return the found transform node or null if not found at all.
  92489. */
  92490. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92491. /**
  92492. * Gets a list of transform nodes using their id
  92493. * @param id defines the id to search for
  92494. * @returns a list of transform nodes
  92495. */
  92496. getTransformNodesByID(id: string): Array<TransformNode>;
  92497. /**
  92498. * Gets a mesh with its auto-generated unique id
  92499. * @param uniqueId defines the unique id to search for
  92500. * @return the found mesh or null if not found at all.
  92501. */
  92502. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92503. /**
  92504. * Gets a the last added mesh using a given id
  92505. * @param id defines the id to search for
  92506. * @return the found mesh or null if not found at all.
  92507. */
  92508. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92509. /**
  92510. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92511. * @param id defines the id to search for
  92512. * @return the found node or null if not found at all
  92513. */
  92514. getLastEntryByID(id: string): Nullable<Node>;
  92515. /**
  92516. * Gets a node (Mesh, Camera, Light) using a given id
  92517. * @param id defines the id to search for
  92518. * @return the found node or null if not found at all
  92519. */
  92520. getNodeByID(id: string): Nullable<Node>;
  92521. /**
  92522. * Gets a node (Mesh, Camera, Light) using a given name
  92523. * @param name defines the name to search for
  92524. * @return the found node or null if not found at all.
  92525. */
  92526. getNodeByName(name: string): Nullable<Node>;
  92527. /**
  92528. * Gets a mesh using a given name
  92529. * @param name defines the name to search for
  92530. * @return the found mesh or null if not found at all.
  92531. */
  92532. getMeshByName(name: string): Nullable<AbstractMesh>;
  92533. /**
  92534. * Gets a transform node using a given name
  92535. * @param name defines the name to search for
  92536. * @return the found transform node or null if not found at all.
  92537. */
  92538. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92539. /**
  92540. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92541. * @param id defines the id to search for
  92542. * @return the found skeleton or null if not found at all.
  92543. */
  92544. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92545. /**
  92546. * Gets a skeleton using a given auto generated unique id
  92547. * @param uniqueId defines the unique id to search for
  92548. * @return the found skeleton or null if not found at all.
  92549. */
  92550. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92551. /**
  92552. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92553. * @param id defines the id to search for
  92554. * @return the found skeleton or null if not found at all.
  92555. */
  92556. getSkeletonById(id: string): Nullable<Skeleton>;
  92557. /**
  92558. * Gets a skeleton using a given name
  92559. * @param name defines the name to search for
  92560. * @return the found skeleton or null if not found at all.
  92561. */
  92562. getSkeletonByName(name: string): Nullable<Skeleton>;
  92563. /**
  92564. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92565. * @param id defines the id to search for
  92566. * @return the found morph target manager or null if not found at all.
  92567. */
  92568. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92569. /**
  92570. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92571. * @param id defines the id to search for
  92572. * @return the found morph target or null if not found at all.
  92573. */
  92574. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92575. /**
  92576. * Gets a boolean indicating if the given mesh is active
  92577. * @param mesh defines the mesh to look for
  92578. * @returns true if the mesh is in the active list
  92579. */
  92580. isActiveMesh(mesh: AbstractMesh): boolean;
  92581. /**
  92582. * Return a unique id as a string which can serve as an identifier for the scene
  92583. */
  92584. readonly uid: string;
  92585. /**
  92586. * Add an externaly attached data from its key.
  92587. * This method call will fail and return false, if such key already exists.
  92588. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92589. * @param key the unique key that identifies the data
  92590. * @param data the data object to associate to the key for this Engine instance
  92591. * @return true if no such key were already present and the data was added successfully, false otherwise
  92592. */
  92593. addExternalData<T>(key: string, data: T): boolean;
  92594. /**
  92595. * Get an externaly attached data from its key
  92596. * @param key the unique key that identifies the data
  92597. * @return the associated data, if present (can be null), or undefined if not present
  92598. */
  92599. getExternalData<T>(key: string): Nullable<T>;
  92600. /**
  92601. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92602. * @param key the unique key that identifies the data
  92603. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92604. * @return the associated data, can be null if the factory returned null.
  92605. */
  92606. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92607. /**
  92608. * Remove an externaly attached data from the Engine instance
  92609. * @param key the unique key that identifies the data
  92610. * @return true if the data was successfully removed, false if it doesn't exist
  92611. */
  92612. removeExternalData(key: string): boolean;
  92613. private _evaluateSubMesh;
  92614. /**
  92615. * Clear the processed materials smart array preventing retention point in material dispose.
  92616. */
  92617. freeProcessedMaterials(): void;
  92618. private _preventFreeActiveMeshesAndRenderingGroups;
  92619. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92620. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92621. * when disposing several meshes in a row or a hierarchy of meshes.
  92622. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92623. */
  92624. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92625. /**
  92626. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92627. */
  92628. freeActiveMeshes(): void;
  92629. /**
  92630. * Clear the info related to rendering groups preventing retention points during dispose.
  92631. */
  92632. freeRenderingGroups(): void;
  92633. /** @hidden */
  92634. _isInIntermediateRendering(): boolean;
  92635. /**
  92636. * Lambda returning the list of potentially active meshes.
  92637. */
  92638. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92639. /**
  92640. * Lambda returning the list of potentially active sub meshes.
  92641. */
  92642. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92643. /**
  92644. * Lambda returning the list of potentially intersecting sub meshes.
  92645. */
  92646. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92647. /**
  92648. * Lambda returning the list of potentially colliding sub meshes.
  92649. */
  92650. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92651. private _activeMeshesFrozen;
  92652. /**
  92653. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92654. * @returns the current scene
  92655. */
  92656. freezeActiveMeshes(): Scene;
  92657. /**
  92658. * Use this function to restart evaluating active meshes on every frame
  92659. * @returns the current scene
  92660. */
  92661. unfreezeActiveMeshes(): Scene;
  92662. private _evaluateActiveMeshes;
  92663. private _activeMesh;
  92664. /**
  92665. * Update the transform matrix to update from the current active camera
  92666. * @param force defines a boolean used to force the update even if cache is up to date
  92667. */
  92668. updateTransformMatrix(force?: boolean): void;
  92669. private _bindFrameBuffer;
  92670. /** @hidden */
  92671. _allowPostProcessClearColor: boolean;
  92672. /** @hidden */
  92673. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92674. private _processSubCameras;
  92675. private _checkIntersections;
  92676. /** @hidden */
  92677. _advancePhysicsEngineStep(step: number): void;
  92678. /**
  92679. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92680. */
  92681. getDeterministicFrameTime: () => number;
  92682. /** @hidden */
  92683. _animate(): void;
  92684. /** Execute all animations (for a frame) */
  92685. animate(): void;
  92686. /**
  92687. * Render the scene
  92688. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92689. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  92690. */
  92691. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  92692. /**
  92693. * Freeze all materials
  92694. * A frozen material will not be updatable but should be faster to render
  92695. */
  92696. freezeMaterials(): void;
  92697. /**
  92698. * Unfreeze all materials
  92699. * A frozen material will not be updatable but should be faster to render
  92700. */
  92701. unfreezeMaterials(): void;
  92702. /**
  92703. * Releases all held ressources
  92704. */
  92705. dispose(): void;
  92706. /**
  92707. * Gets if the scene is already disposed
  92708. */
  92709. readonly isDisposed: boolean;
  92710. /**
  92711. * Call this function to reduce memory footprint of the scene.
  92712. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92713. */
  92714. clearCachedVertexData(): void;
  92715. /**
  92716. * This function will remove the local cached buffer data from texture.
  92717. * It will save memory but will prevent the texture from being rebuilt
  92718. */
  92719. cleanCachedTextureBuffer(): void;
  92720. /**
  92721. * Get the world extend vectors with an optional filter
  92722. *
  92723. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92724. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92725. */
  92726. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92727. min: Vector3;
  92728. max: Vector3;
  92729. };
  92730. /**
  92731. * Creates a ray that can be used to pick in the scene
  92732. * @param x defines the x coordinate of the origin (on-screen)
  92733. * @param y defines the y coordinate of the origin (on-screen)
  92734. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92735. * @param camera defines the camera to use for the picking
  92736. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92737. * @returns a Ray
  92738. */
  92739. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92740. /**
  92741. * Creates a ray that can be used to pick in the scene
  92742. * @param x defines the x coordinate of the origin (on-screen)
  92743. * @param y defines the y coordinate of the origin (on-screen)
  92744. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92745. * @param result defines the ray where to store the picking ray
  92746. * @param camera defines the camera to use for the picking
  92747. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92748. * @returns the current scene
  92749. */
  92750. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92751. /**
  92752. * Creates a ray that can be used to pick in the scene
  92753. * @param x defines the x coordinate of the origin (on-screen)
  92754. * @param y defines the y coordinate of the origin (on-screen)
  92755. * @param camera defines the camera to use for the picking
  92756. * @returns a Ray
  92757. */
  92758. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92759. /**
  92760. * Creates a ray that can be used to pick in the scene
  92761. * @param x defines the x coordinate of the origin (on-screen)
  92762. * @param y defines the y coordinate of the origin (on-screen)
  92763. * @param result defines the ray where to store the picking ray
  92764. * @param camera defines the camera to use for the picking
  92765. * @returns the current scene
  92766. */
  92767. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92768. /** Launch a ray to try to pick a mesh in the scene
  92769. * @param x position on screen
  92770. * @param y position on screen
  92771. * @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
  92772. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92773. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92774. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92775. * @returns a PickingInfo
  92776. */
  92777. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92778. /** Use the given ray to pick a mesh in the scene
  92779. * @param ray The ray to use to pick meshes
  92780. * @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
  92781. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92782. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92783. * @returns a PickingInfo
  92784. */
  92785. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92786. /**
  92787. * Launch a ray to try to pick a mesh in the scene
  92788. * @param x X position on screen
  92789. * @param y Y position on screen
  92790. * @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
  92791. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92792. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92793. * @returns an array of PickingInfo
  92794. */
  92795. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92796. /**
  92797. * Launch a ray to try to pick a mesh in the scene
  92798. * @param ray Ray to use
  92799. * @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
  92800. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92801. * @returns an array of PickingInfo
  92802. */
  92803. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92804. /**
  92805. * Force the value of meshUnderPointer
  92806. * @param mesh defines the mesh to use
  92807. */
  92808. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  92809. /**
  92810. * Gets the mesh under the pointer
  92811. * @returns a Mesh or null if no mesh is under the pointer
  92812. */
  92813. getPointerOverMesh(): Nullable<AbstractMesh>;
  92814. /** @hidden */
  92815. _rebuildGeometries(): void;
  92816. /** @hidden */
  92817. _rebuildTextures(): void;
  92818. private _getByTags;
  92819. /**
  92820. * Get a list of meshes by tags
  92821. * @param tagsQuery defines the tags query to use
  92822. * @param forEach defines a predicate used to filter results
  92823. * @returns an array of Mesh
  92824. */
  92825. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  92826. /**
  92827. * Get a list of cameras by tags
  92828. * @param tagsQuery defines the tags query to use
  92829. * @param forEach defines a predicate used to filter results
  92830. * @returns an array of Camera
  92831. */
  92832. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  92833. /**
  92834. * Get a list of lights by tags
  92835. * @param tagsQuery defines the tags query to use
  92836. * @param forEach defines a predicate used to filter results
  92837. * @returns an array of Light
  92838. */
  92839. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  92840. /**
  92841. * Get a list of materials by tags
  92842. * @param tagsQuery defines the tags query to use
  92843. * @param forEach defines a predicate used to filter results
  92844. * @returns an array of Material
  92845. */
  92846. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  92847. /**
  92848. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  92849. * This allowed control for front to back rendering or reversly depending of the special needs.
  92850. *
  92851. * @param renderingGroupId The rendering group id corresponding to its index
  92852. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  92853. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  92854. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  92855. */
  92856. 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;
  92857. /**
  92858. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  92859. *
  92860. * @param renderingGroupId The rendering group id corresponding to its index
  92861. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  92862. * @param depth Automatically clears depth between groups if true and autoClear is true.
  92863. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  92864. */
  92865. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  92866. /**
  92867. * Gets the current auto clear configuration for one rendering group of the rendering
  92868. * manager.
  92869. * @param index the rendering group index to get the information for
  92870. * @returns The auto clear setup for the requested rendering group
  92871. */
  92872. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  92873. private _blockMaterialDirtyMechanism;
  92874. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  92875. blockMaterialDirtyMechanism: boolean;
  92876. /**
  92877. * Will flag all materials as dirty to trigger new shader compilation
  92878. * @param flag defines the flag used to specify which material part must be marked as dirty
  92879. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  92880. */
  92881. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  92882. /** @hidden */
  92883. _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;
  92884. /** @hidden */
  92885. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  92886. }
  92887. }
  92888. declare module BABYLON {
  92889. /**
  92890. * Set of assets to keep when moving a scene into an asset container.
  92891. */
  92892. export class KeepAssets extends AbstractScene {
  92893. }
  92894. /**
  92895. * Container with a set of assets that can be added or removed from a scene.
  92896. */
  92897. export class AssetContainer extends AbstractScene {
  92898. /**
  92899. * The scene the AssetContainer belongs to.
  92900. */
  92901. scene: Scene;
  92902. /**
  92903. * Instantiates an AssetContainer.
  92904. * @param scene The scene the AssetContainer belongs to.
  92905. */
  92906. constructor(scene: Scene);
  92907. /**
  92908. * Adds all the assets from the container to the scene.
  92909. */
  92910. addAllToScene(): void;
  92911. /**
  92912. * Removes all the assets in the container from the scene
  92913. */
  92914. removeAllFromScene(): void;
  92915. /**
  92916. * Disposes all the assets in the container
  92917. */
  92918. dispose(): void;
  92919. private _moveAssets;
  92920. /**
  92921. * Removes all the assets contained in the scene and adds them to the container.
  92922. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  92923. */
  92924. moveAllFromScene(keepAssets?: KeepAssets): void;
  92925. /**
  92926. * 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.
  92927. * @returns the root mesh
  92928. */
  92929. createRootMesh(): Mesh;
  92930. }
  92931. }
  92932. declare module BABYLON {
  92933. /**
  92934. * Defines how the parser contract is defined.
  92935. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  92936. */
  92937. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  92938. /**
  92939. * Defines how the individual parser contract is defined.
  92940. * These parser can parse an individual asset
  92941. */
  92942. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  92943. /**
  92944. * Base class of the scene acting as a container for the different elements composing a scene.
  92945. * This class is dynamically extended by the different components of the scene increasing
  92946. * flexibility and reducing coupling
  92947. */
  92948. export abstract class AbstractScene {
  92949. /**
  92950. * Stores the list of available parsers in the application.
  92951. */
  92952. private static _BabylonFileParsers;
  92953. /**
  92954. * Stores the list of available individual parsers in the application.
  92955. */
  92956. private static _IndividualBabylonFileParsers;
  92957. /**
  92958. * Adds a parser in the list of available ones
  92959. * @param name Defines the name of the parser
  92960. * @param parser Defines the parser to add
  92961. */
  92962. static AddParser(name: string, parser: BabylonFileParser): void;
  92963. /**
  92964. * Gets a general parser from the list of avaialble ones
  92965. * @param name Defines the name of the parser
  92966. * @returns the requested parser or null
  92967. */
  92968. static GetParser(name: string): Nullable<BabylonFileParser>;
  92969. /**
  92970. * Adds n individual parser in the list of available ones
  92971. * @param name Defines the name of the parser
  92972. * @param parser Defines the parser to add
  92973. */
  92974. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  92975. /**
  92976. * Gets an individual parser from the list of avaialble ones
  92977. * @param name Defines the name of the parser
  92978. * @returns the requested parser or null
  92979. */
  92980. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  92981. /**
  92982. * Parser json data and populate both a scene and its associated container object
  92983. * @param jsonData Defines the data to parse
  92984. * @param scene Defines the scene to parse the data for
  92985. * @param container Defines the container attached to the parsing sequence
  92986. * @param rootUrl Defines the root url of the data
  92987. */
  92988. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  92989. /**
  92990. * Gets the list of root nodes (ie. nodes with no parent)
  92991. */
  92992. rootNodes: Node[];
  92993. /** All of the cameras added to this scene
  92994. * @see http://doc.babylonjs.com/babylon101/cameras
  92995. */
  92996. cameras: Camera[];
  92997. /**
  92998. * All of the lights added to this scene
  92999. * @see http://doc.babylonjs.com/babylon101/lights
  93000. */
  93001. lights: Light[];
  93002. /**
  93003. * All of the (abstract) meshes added to this scene
  93004. */
  93005. meshes: AbstractMesh[];
  93006. /**
  93007. * The list of skeletons added to the scene
  93008. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93009. */
  93010. skeletons: Skeleton[];
  93011. /**
  93012. * All of the particle systems added to this scene
  93013. * @see http://doc.babylonjs.com/babylon101/particles
  93014. */
  93015. particleSystems: IParticleSystem[];
  93016. /**
  93017. * Gets a list of Animations associated with the scene
  93018. */
  93019. animations: Animation[];
  93020. /**
  93021. * All of the animation groups added to this scene
  93022. * @see http://doc.babylonjs.com/how_to/group
  93023. */
  93024. animationGroups: AnimationGroup[];
  93025. /**
  93026. * All of the multi-materials added to this scene
  93027. * @see http://doc.babylonjs.com/how_to/multi_materials
  93028. */
  93029. multiMaterials: MultiMaterial[];
  93030. /**
  93031. * All of the materials added to this scene
  93032. * In the context of a Scene, it is not supposed to be modified manually.
  93033. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93034. * Note also that the order of the Material wihin the array is not significant and might change.
  93035. * @see http://doc.babylonjs.com/babylon101/materials
  93036. */
  93037. materials: Material[];
  93038. /**
  93039. * The list of morph target managers added to the scene
  93040. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93041. */
  93042. morphTargetManagers: MorphTargetManager[];
  93043. /**
  93044. * The list of geometries used in the scene.
  93045. */
  93046. geometries: Geometry[];
  93047. /**
  93048. * All of the tranform nodes added to this scene
  93049. * In the context of a Scene, it is not supposed to be modified manually.
  93050. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93051. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93052. * @see http://doc.babylonjs.com/how_to/transformnode
  93053. */
  93054. transformNodes: TransformNode[];
  93055. /**
  93056. * ActionManagers available on the scene.
  93057. */
  93058. actionManagers: AbstractActionManager[];
  93059. /**
  93060. * Textures to keep.
  93061. */
  93062. textures: BaseTexture[];
  93063. /**
  93064. * Environment texture for the scene
  93065. */
  93066. environmentTexture: Nullable<BaseTexture>;
  93067. }
  93068. }
  93069. declare module BABYLON {
  93070. /**
  93071. * Defines a sound that can be played in the application.
  93072. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93073. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93074. */
  93075. export class Sound {
  93076. /**
  93077. * The name of the sound in the scene.
  93078. */
  93079. name: string;
  93080. /**
  93081. * Does the sound autoplay once loaded.
  93082. */
  93083. autoplay: boolean;
  93084. /**
  93085. * Does the sound loop after it finishes playing once.
  93086. */
  93087. loop: boolean;
  93088. /**
  93089. * Does the sound use a custom attenuation curve to simulate the falloff
  93090. * happening when the source gets further away from the camera.
  93091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93092. */
  93093. useCustomAttenuation: boolean;
  93094. /**
  93095. * The sound track id this sound belongs to.
  93096. */
  93097. soundTrackId: number;
  93098. /**
  93099. * Is this sound currently played.
  93100. */
  93101. isPlaying: boolean;
  93102. /**
  93103. * Is this sound currently paused.
  93104. */
  93105. isPaused: boolean;
  93106. /**
  93107. * Does this sound enables spatial sound.
  93108. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93109. */
  93110. spatialSound: boolean;
  93111. /**
  93112. * Define the reference distance the sound should be heard perfectly.
  93113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93114. */
  93115. refDistance: number;
  93116. /**
  93117. * Define the roll off factor of spatial sounds.
  93118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93119. */
  93120. rolloffFactor: number;
  93121. /**
  93122. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93123. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93124. */
  93125. maxDistance: number;
  93126. /**
  93127. * Define the distance attenuation model the sound will follow.
  93128. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93129. */
  93130. distanceModel: string;
  93131. /**
  93132. * @hidden
  93133. * Back Compat
  93134. **/
  93135. onended: () => any;
  93136. /**
  93137. * Observable event when the current playing sound finishes.
  93138. */
  93139. onEndedObservable: Observable<Sound>;
  93140. private _panningModel;
  93141. private _playbackRate;
  93142. private _streaming;
  93143. private _startTime;
  93144. private _startOffset;
  93145. private _position;
  93146. /** @hidden */
  93147. _positionInEmitterSpace: boolean;
  93148. private _localDirection;
  93149. private _volume;
  93150. private _isReadyToPlay;
  93151. private _isDirectional;
  93152. private _readyToPlayCallback;
  93153. private _audioBuffer;
  93154. private _soundSource;
  93155. private _streamingSource;
  93156. private _soundPanner;
  93157. private _soundGain;
  93158. private _inputAudioNode;
  93159. private _outputAudioNode;
  93160. private _coneInnerAngle;
  93161. private _coneOuterAngle;
  93162. private _coneOuterGain;
  93163. private _scene;
  93164. private _connectedTransformNode;
  93165. private _customAttenuationFunction;
  93166. private _registerFunc;
  93167. private _isOutputConnected;
  93168. private _htmlAudioElement;
  93169. private _urlType;
  93170. /** @hidden */
  93171. static _SceneComponentInitialization: (scene: Scene) => void;
  93172. /**
  93173. * Create a sound and attach it to a scene
  93174. * @param name Name of your sound
  93175. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93176. * @param scene defines the scene the sound belongs to
  93177. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93178. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93179. */
  93180. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93181. /**
  93182. * Release the sound and its associated resources
  93183. */
  93184. dispose(): void;
  93185. /**
  93186. * Gets if the sounds is ready to be played or not.
  93187. * @returns true if ready, otherwise false
  93188. */
  93189. isReady(): boolean;
  93190. private _soundLoaded;
  93191. /**
  93192. * Sets the data of the sound from an audiobuffer
  93193. * @param audioBuffer The audioBuffer containing the data
  93194. */
  93195. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93196. /**
  93197. * Updates the current sounds options such as maxdistance, loop...
  93198. * @param options A JSON object containing values named as the object properties
  93199. */
  93200. updateOptions(options: any): void;
  93201. private _createSpatialParameters;
  93202. private _updateSpatialParameters;
  93203. /**
  93204. * Switch the panning model to HRTF:
  93205. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93206. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93207. */
  93208. switchPanningModelToHRTF(): void;
  93209. /**
  93210. * Switch the panning model to Equal Power:
  93211. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93212. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93213. */
  93214. switchPanningModelToEqualPower(): void;
  93215. private _switchPanningModel;
  93216. /**
  93217. * Connect this sound to a sound track audio node like gain...
  93218. * @param soundTrackAudioNode the sound track audio node to connect to
  93219. */
  93220. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93221. /**
  93222. * Transform this sound into a directional source
  93223. * @param coneInnerAngle Size of the inner cone in degree
  93224. * @param coneOuterAngle Size of the outer cone in degree
  93225. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93226. */
  93227. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93228. /**
  93229. * Gets or sets the inner angle for the directional cone.
  93230. */
  93231. /**
  93232. * Gets or sets the inner angle for the directional cone.
  93233. */
  93234. directionalConeInnerAngle: number;
  93235. /**
  93236. * Gets or sets the outer angle for the directional cone.
  93237. */
  93238. /**
  93239. * Gets or sets the outer angle for the directional cone.
  93240. */
  93241. directionalConeOuterAngle: number;
  93242. /**
  93243. * Sets the position of the emitter if spatial sound is enabled
  93244. * @param newPosition Defines the new posisiton
  93245. */
  93246. setPosition(newPosition: Vector3): void;
  93247. /**
  93248. * Sets the local direction of the emitter if spatial sound is enabled
  93249. * @param newLocalDirection Defines the new local direction
  93250. */
  93251. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93252. private _updateDirection;
  93253. /** @hidden */
  93254. updateDistanceFromListener(): void;
  93255. /**
  93256. * Sets a new custom attenuation function for the sound.
  93257. * @param callback Defines the function used for the attenuation
  93258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93259. */
  93260. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93261. /**
  93262. * Play the sound
  93263. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93264. * @param offset (optional) Start the sound setting it at a specific time
  93265. */
  93266. play(time?: number, offset?: number): void;
  93267. private _onended;
  93268. /**
  93269. * Stop the sound
  93270. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93271. */
  93272. stop(time?: number): void;
  93273. /**
  93274. * Put the sound in pause
  93275. */
  93276. pause(): void;
  93277. /**
  93278. * Sets a dedicated volume for this sounds
  93279. * @param newVolume Define the new volume of the sound
  93280. * @param time Define in how long the sound should be at this value
  93281. */
  93282. setVolume(newVolume: number, time?: number): void;
  93283. /**
  93284. * Set the sound play back rate
  93285. * @param newPlaybackRate Define the playback rate the sound should be played at
  93286. */
  93287. setPlaybackRate(newPlaybackRate: number): void;
  93288. /**
  93289. * Gets the volume of the sound.
  93290. * @returns the volume of the sound
  93291. */
  93292. getVolume(): number;
  93293. /**
  93294. * Attach the sound to a dedicated mesh
  93295. * @param transformNode The transform node to connect the sound with
  93296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93297. */
  93298. attachToMesh(transformNode: TransformNode): void;
  93299. /**
  93300. * Detach the sound from the previously attached mesh
  93301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93302. */
  93303. detachFromMesh(): void;
  93304. private _onRegisterAfterWorldMatrixUpdate;
  93305. /**
  93306. * Clone the current sound in the scene.
  93307. * @returns the new sound clone
  93308. */
  93309. clone(): Nullable<Sound>;
  93310. /**
  93311. * Gets the current underlying audio buffer containing the data
  93312. * @returns the audio buffer
  93313. */
  93314. getAudioBuffer(): Nullable<AudioBuffer>;
  93315. /**
  93316. * Serializes the Sound in a JSON representation
  93317. * @returns the JSON representation of the sound
  93318. */
  93319. serialize(): any;
  93320. /**
  93321. * Parse a JSON representation of a sound to innstantiate in a given scene
  93322. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93323. * @param scene Define the scene the new parsed sound should be created in
  93324. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93325. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93326. * @returns the newly parsed sound
  93327. */
  93328. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93329. }
  93330. }
  93331. declare module BABYLON {
  93332. /**
  93333. * This defines an action helpful to play a defined sound on a triggered action.
  93334. */
  93335. export class PlaySoundAction extends Action {
  93336. private _sound;
  93337. /**
  93338. * Instantiate the action
  93339. * @param triggerOptions defines the trigger options
  93340. * @param sound defines the sound to play
  93341. * @param condition defines the trigger related conditions
  93342. */
  93343. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93344. /** @hidden */
  93345. _prepare(): void;
  93346. /**
  93347. * Execute the action and play the sound.
  93348. */
  93349. execute(): void;
  93350. /**
  93351. * Serializes the actions and its related information.
  93352. * @param parent defines the object to serialize in
  93353. * @returns the serialized object
  93354. */
  93355. serialize(parent: any): any;
  93356. }
  93357. /**
  93358. * This defines an action helpful to stop a defined sound on a triggered action.
  93359. */
  93360. export class StopSoundAction extends Action {
  93361. private _sound;
  93362. /**
  93363. * Instantiate the action
  93364. * @param triggerOptions defines the trigger options
  93365. * @param sound defines the sound to stop
  93366. * @param condition defines the trigger related conditions
  93367. */
  93368. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93369. /** @hidden */
  93370. _prepare(): void;
  93371. /**
  93372. * Execute the action and stop the sound.
  93373. */
  93374. execute(): void;
  93375. /**
  93376. * Serializes the actions and its related information.
  93377. * @param parent defines the object to serialize in
  93378. * @returns the serialized object
  93379. */
  93380. serialize(parent: any): any;
  93381. }
  93382. }
  93383. declare module BABYLON {
  93384. /**
  93385. * This defines an action responsible to change the value of a property
  93386. * by interpolating between its current value and the newly set one once triggered.
  93387. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93388. */
  93389. export class InterpolateValueAction extends Action {
  93390. /**
  93391. * Defines the path of the property where the value should be interpolated
  93392. */
  93393. propertyPath: string;
  93394. /**
  93395. * Defines the target value at the end of the interpolation.
  93396. */
  93397. value: any;
  93398. /**
  93399. * Defines the time it will take for the property to interpolate to the value.
  93400. */
  93401. duration: number;
  93402. /**
  93403. * Defines if the other scene animations should be stopped when the action has been triggered
  93404. */
  93405. stopOtherAnimations?: boolean;
  93406. /**
  93407. * Defines a callback raised once the interpolation animation has been done.
  93408. */
  93409. onInterpolationDone?: () => void;
  93410. /**
  93411. * Observable triggered once the interpolation animation has been done.
  93412. */
  93413. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93414. private _target;
  93415. private _effectiveTarget;
  93416. private _property;
  93417. /**
  93418. * Instantiate the action
  93419. * @param triggerOptions defines the trigger options
  93420. * @param target defines the object containing the value to interpolate
  93421. * @param propertyPath defines the path to the property in the target object
  93422. * @param value defines the target value at the end of the interpolation
  93423. * @param duration deines the time it will take for the property to interpolate to the value.
  93424. * @param condition defines the trigger related conditions
  93425. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93426. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93427. */
  93428. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93429. /** @hidden */
  93430. _prepare(): void;
  93431. /**
  93432. * Execute the action starts the value interpolation.
  93433. */
  93434. execute(): void;
  93435. /**
  93436. * Serializes the actions and its related information.
  93437. * @param parent defines the object to serialize in
  93438. * @returns the serialized object
  93439. */
  93440. serialize(parent: any): any;
  93441. }
  93442. }
  93443. declare module BABYLON {
  93444. /**
  93445. * Options allowed during the creation of a sound track.
  93446. */
  93447. export interface ISoundTrackOptions {
  93448. /**
  93449. * The volume the sound track should take during creation
  93450. */
  93451. volume?: number;
  93452. /**
  93453. * Define if the sound track is the main sound track of the scene
  93454. */
  93455. mainTrack?: boolean;
  93456. }
  93457. /**
  93458. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93459. * It will be also used in a future release to apply effects on a specific track.
  93460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93461. */
  93462. export class SoundTrack {
  93463. /**
  93464. * The unique identifier of the sound track in the scene.
  93465. */
  93466. id: number;
  93467. /**
  93468. * The list of sounds included in the sound track.
  93469. */
  93470. soundCollection: Array<Sound>;
  93471. private _outputAudioNode;
  93472. private _scene;
  93473. private _isMainTrack;
  93474. private _connectedAnalyser;
  93475. private _options;
  93476. private _isInitialized;
  93477. /**
  93478. * Creates a new sound track.
  93479. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93480. * @param scene Define the scene the sound track belongs to
  93481. * @param options
  93482. */
  93483. constructor(scene: Scene, options?: ISoundTrackOptions);
  93484. private _initializeSoundTrackAudioGraph;
  93485. /**
  93486. * Release the sound track and its associated resources
  93487. */
  93488. dispose(): void;
  93489. /**
  93490. * Adds a sound to this sound track
  93491. * @param sound define the cound to add
  93492. * @ignoreNaming
  93493. */
  93494. AddSound(sound: Sound): void;
  93495. /**
  93496. * Removes a sound to this sound track
  93497. * @param sound define the cound to remove
  93498. * @ignoreNaming
  93499. */
  93500. RemoveSound(sound: Sound): void;
  93501. /**
  93502. * Set a global volume for the full sound track.
  93503. * @param newVolume Define the new volume of the sound track
  93504. */
  93505. setVolume(newVolume: number): void;
  93506. /**
  93507. * Switch the panning model to HRTF:
  93508. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93510. */
  93511. switchPanningModelToHRTF(): void;
  93512. /**
  93513. * Switch the panning model to Equal Power:
  93514. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93515. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93516. */
  93517. switchPanningModelToEqualPower(): void;
  93518. /**
  93519. * Connect the sound track to an audio analyser allowing some amazing
  93520. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93521. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93522. * @param analyser The analyser to connect to the engine
  93523. */
  93524. connectToAnalyser(analyser: Analyser): void;
  93525. }
  93526. }
  93527. declare module BABYLON {
  93528. interface AbstractScene {
  93529. /**
  93530. * The list of sounds used in the scene.
  93531. */
  93532. sounds: Nullable<Array<Sound>>;
  93533. }
  93534. interface Scene {
  93535. /**
  93536. * @hidden
  93537. * Backing field
  93538. */
  93539. _mainSoundTrack: SoundTrack;
  93540. /**
  93541. * The main sound track played by the scene.
  93542. * It cotains your primary collection of sounds.
  93543. */
  93544. mainSoundTrack: SoundTrack;
  93545. /**
  93546. * The list of sound tracks added to the scene
  93547. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93548. */
  93549. soundTracks: Nullable<Array<SoundTrack>>;
  93550. /**
  93551. * Gets a sound using a given name
  93552. * @param name defines the name to search for
  93553. * @return the found sound or null if not found at all.
  93554. */
  93555. getSoundByName(name: string): Nullable<Sound>;
  93556. /**
  93557. * Gets or sets if audio support is enabled
  93558. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93559. */
  93560. audioEnabled: boolean;
  93561. /**
  93562. * Gets or sets if audio will be output to headphones
  93563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93564. */
  93565. headphone: boolean;
  93566. }
  93567. /**
  93568. * Defines the sound scene component responsible to manage any sounds
  93569. * in a given scene.
  93570. */
  93571. export class AudioSceneComponent implements ISceneSerializableComponent {
  93572. /**
  93573. * The component name helpfull to identify the component in the list of scene components.
  93574. */
  93575. readonly name: string;
  93576. /**
  93577. * The scene the component belongs to.
  93578. */
  93579. scene: Scene;
  93580. private _audioEnabled;
  93581. /**
  93582. * Gets whether audio is enabled or not.
  93583. * Please use related enable/disable method to switch state.
  93584. */
  93585. readonly audioEnabled: boolean;
  93586. private _headphone;
  93587. /**
  93588. * Gets whether audio is outputing to headphone or not.
  93589. * Please use the according Switch methods to change output.
  93590. */
  93591. readonly headphone: boolean;
  93592. /**
  93593. * Creates a new instance of the component for the given scene
  93594. * @param scene Defines the scene to register the component in
  93595. */
  93596. constructor(scene: Scene);
  93597. /**
  93598. * Registers the component in a given scene
  93599. */
  93600. register(): void;
  93601. /**
  93602. * Rebuilds the elements related to this component in case of
  93603. * context lost for instance.
  93604. */
  93605. rebuild(): void;
  93606. /**
  93607. * Serializes the component data to the specified json object
  93608. * @param serializationObject The object to serialize to
  93609. */
  93610. serialize(serializationObject: any): void;
  93611. /**
  93612. * Adds all the element from the container to the scene
  93613. * @param container the container holding the elements
  93614. */
  93615. addFromContainer(container: AbstractScene): void;
  93616. /**
  93617. * Removes all the elements in the container from the scene
  93618. * @param container contains the elements to remove
  93619. * @param dispose if the removed element should be disposed (default: false)
  93620. */
  93621. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93622. /**
  93623. * Disposes the component and the associated ressources.
  93624. */
  93625. dispose(): void;
  93626. /**
  93627. * Disables audio in the associated scene.
  93628. */
  93629. disableAudio(): void;
  93630. /**
  93631. * Enables audio in the associated scene.
  93632. */
  93633. enableAudio(): void;
  93634. /**
  93635. * Switch audio to headphone output.
  93636. */
  93637. switchAudioModeForHeadphones(): void;
  93638. /**
  93639. * Switch audio to normal speakers.
  93640. */
  93641. switchAudioModeForNormalSpeakers(): void;
  93642. private _afterRender;
  93643. }
  93644. }
  93645. declare module BABYLON {
  93646. /**
  93647. * Wraps one or more Sound objects and selects one with random weight for playback.
  93648. */
  93649. export class WeightedSound {
  93650. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93651. loop: boolean;
  93652. private _coneInnerAngle;
  93653. private _coneOuterAngle;
  93654. private _volume;
  93655. /** A Sound is currently playing. */
  93656. isPlaying: boolean;
  93657. /** A Sound is currently paused. */
  93658. isPaused: boolean;
  93659. private _sounds;
  93660. private _weights;
  93661. private _currentIndex?;
  93662. /**
  93663. * Creates a new WeightedSound from the list of sounds given.
  93664. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93665. * @param sounds Array of Sounds that will be selected from.
  93666. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93667. */
  93668. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93669. /**
  93670. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93671. */
  93672. /**
  93673. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93674. */
  93675. directionalConeInnerAngle: number;
  93676. /**
  93677. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93678. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93679. */
  93680. /**
  93681. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93682. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93683. */
  93684. directionalConeOuterAngle: number;
  93685. /**
  93686. * Playback volume.
  93687. */
  93688. /**
  93689. * Playback volume.
  93690. */
  93691. volume: number;
  93692. private _onended;
  93693. /**
  93694. * Suspend playback
  93695. */
  93696. pause(): void;
  93697. /**
  93698. * Stop playback
  93699. */
  93700. stop(): void;
  93701. /**
  93702. * Start playback.
  93703. * @param startOffset Position the clip head at a specific time in seconds.
  93704. */
  93705. play(startOffset?: number): void;
  93706. }
  93707. }
  93708. declare module BABYLON {
  93709. /**
  93710. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93711. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93712. */
  93713. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93714. /**
  93715. * Gets the name of the behavior.
  93716. */
  93717. readonly name: string;
  93718. /**
  93719. * The easing function used by animations
  93720. */
  93721. static EasingFunction: BackEase;
  93722. /**
  93723. * The easing mode used by animations
  93724. */
  93725. static EasingMode: number;
  93726. /**
  93727. * The duration of the animation, in milliseconds
  93728. */
  93729. transitionDuration: number;
  93730. /**
  93731. * Length of the distance animated by the transition when lower radius is reached
  93732. */
  93733. lowerRadiusTransitionRange: number;
  93734. /**
  93735. * Length of the distance animated by the transition when upper radius is reached
  93736. */
  93737. upperRadiusTransitionRange: number;
  93738. private _autoTransitionRange;
  93739. /**
  93740. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93741. */
  93742. /**
  93743. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93744. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93745. */
  93746. autoTransitionRange: boolean;
  93747. private _attachedCamera;
  93748. private _onAfterCheckInputsObserver;
  93749. private _onMeshTargetChangedObserver;
  93750. /**
  93751. * Initializes the behavior.
  93752. */
  93753. init(): void;
  93754. /**
  93755. * Attaches the behavior to its arc rotate camera.
  93756. * @param camera Defines the camera to attach the behavior to
  93757. */
  93758. attach(camera: ArcRotateCamera): void;
  93759. /**
  93760. * Detaches the behavior from its current arc rotate camera.
  93761. */
  93762. detach(): void;
  93763. private _radiusIsAnimating;
  93764. private _radiusBounceTransition;
  93765. private _animatables;
  93766. private _cachedWheelPrecision;
  93767. /**
  93768. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93769. * @param radiusLimit The limit to check against.
  93770. * @return Bool to indicate if at limit.
  93771. */
  93772. private _isRadiusAtLimit;
  93773. /**
  93774. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93775. * @param radiusDelta The delta by which to animate to. Can be negative.
  93776. */
  93777. private _applyBoundRadiusAnimation;
  93778. /**
  93779. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93780. */
  93781. protected _clearAnimationLocks(): void;
  93782. /**
  93783. * Stops and removes all animations that have been applied to the camera
  93784. */
  93785. stopAllAnimations(): void;
  93786. }
  93787. }
  93788. declare module BABYLON {
  93789. /**
  93790. * 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.
  93791. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93792. */
  93793. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93794. /**
  93795. * Gets the name of the behavior.
  93796. */
  93797. readonly name: string;
  93798. private _mode;
  93799. private _radiusScale;
  93800. private _positionScale;
  93801. private _defaultElevation;
  93802. private _elevationReturnTime;
  93803. private _elevationReturnWaitTime;
  93804. private _zoomStopsAnimation;
  93805. private _framingTime;
  93806. /**
  93807. * The easing function used by animations
  93808. */
  93809. static EasingFunction: ExponentialEase;
  93810. /**
  93811. * The easing mode used by animations
  93812. */
  93813. static EasingMode: number;
  93814. /**
  93815. * Sets the current mode used by the behavior
  93816. */
  93817. /**
  93818. * Gets current mode used by the behavior.
  93819. */
  93820. mode: number;
  93821. /**
  93822. * Sets the scale applied to the radius (1 by default)
  93823. */
  93824. /**
  93825. * Gets the scale applied to the radius
  93826. */
  93827. radiusScale: number;
  93828. /**
  93829. * Sets 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. /**
  93832. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  93833. */
  93834. positionScale: number;
  93835. /**
  93836. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93837. * behaviour is triggered, in radians.
  93838. */
  93839. /**
  93840. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  93841. * behaviour is triggered, in radians.
  93842. */
  93843. defaultElevation: number;
  93844. /**
  93845. * Sets the time (in milliseconds) taken to return to the default beta position.
  93846. * Negative value indicates camera should not return to default.
  93847. */
  93848. /**
  93849. * Gets the time (in milliseconds) taken to return to the default beta position.
  93850. * Negative value indicates camera should not return to default.
  93851. */
  93852. elevationReturnTime: number;
  93853. /**
  93854. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93855. */
  93856. /**
  93857. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  93858. */
  93859. elevationReturnWaitTime: number;
  93860. /**
  93861. * Sets the flag that indicates if user zooming should stop animation.
  93862. */
  93863. /**
  93864. * Gets the flag that indicates if user zooming should stop animation.
  93865. */
  93866. zoomStopsAnimation: boolean;
  93867. /**
  93868. * Sets the transition time when framing the mesh, in milliseconds
  93869. */
  93870. /**
  93871. * Gets the transition time when framing the mesh, in milliseconds
  93872. */
  93873. framingTime: number;
  93874. /**
  93875. * Define if the behavior should automatically change the configured
  93876. * camera limits and sensibilities.
  93877. */
  93878. autoCorrectCameraLimitsAndSensibility: boolean;
  93879. private _onPrePointerObservableObserver;
  93880. private _onAfterCheckInputsObserver;
  93881. private _onMeshTargetChangedObserver;
  93882. private _attachedCamera;
  93883. private _isPointerDown;
  93884. private _lastInteractionTime;
  93885. /**
  93886. * Initializes the behavior.
  93887. */
  93888. init(): void;
  93889. /**
  93890. * Attaches the behavior to its arc rotate camera.
  93891. * @param camera Defines the camera to attach the behavior to
  93892. */
  93893. attach(camera: ArcRotateCamera): void;
  93894. /**
  93895. * Detaches the behavior from its current arc rotate camera.
  93896. */
  93897. detach(): void;
  93898. private _animatables;
  93899. private _betaIsAnimating;
  93900. private _betaTransition;
  93901. private _radiusTransition;
  93902. private _vectorTransition;
  93903. /**
  93904. * Targets the given mesh and updates zoom level accordingly.
  93905. * @param mesh The mesh to target.
  93906. * @param radius Optional. If a cached radius position already exists, overrides default.
  93907. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93908. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93909. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93910. */
  93911. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93912. /**
  93913. * Targets the given mesh with its children and updates zoom level accordingly.
  93914. * @param mesh The mesh to target.
  93915. * @param radius Optional. If a cached radius position already exists, overrides default.
  93916. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93917. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93918. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93919. */
  93920. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93921. /**
  93922. * Targets the given meshes with their children and updates zoom level accordingly.
  93923. * @param meshes The mesh to target.
  93924. * @param radius Optional. If a cached radius position already exists, overrides default.
  93925. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  93926. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93927. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93928. */
  93929. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93930. /**
  93931. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  93932. * @param minimumWorld Determines the smaller position of the bounding box extend
  93933. * @param maximumWorld Determines the bigger position of the bounding box extend
  93934. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  93935. * @param onAnimationEnd Callback triggered at the end of the framing animation
  93936. */
  93937. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  93938. /**
  93939. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  93940. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  93941. * frustum width.
  93942. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  93943. * to fully enclose the mesh in the viewing frustum.
  93944. */
  93945. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  93946. /**
  93947. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  93948. * is automatically returned to its default position (expected to be above ground plane).
  93949. */
  93950. private _maintainCameraAboveGround;
  93951. /**
  93952. * Returns the frustum slope based on the canvas ratio and camera FOV
  93953. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  93954. */
  93955. private _getFrustumSlope;
  93956. /**
  93957. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  93958. */
  93959. private _clearAnimationLocks;
  93960. /**
  93961. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  93962. */
  93963. private _applyUserInteraction;
  93964. /**
  93965. * Stops and removes all animations that have been applied to the camera
  93966. */
  93967. stopAllAnimations(): void;
  93968. /**
  93969. * Gets a value indicating if the user is moving the camera
  93970. */
  93971. readonly isUserIsMoving: boolean;
  93972. /**
  93973. * The camera can move all the way towards the mesh.
  93974. */
  93975. static IgnoreBoundsSizeMode: number;
  93976. /**
  93977. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  93978. */
  93979. static FitFrustumSidesMode: number;
  93980. }
  93981. }
  93982. declare module BABYLON {
  93983. /**
  93984. * Base class for Camera Pointer Inputs.
  93985. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  93986. * for example usage.
  93987. */
  93988. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  93989. /**
  93990. * Defines the camera the input is attached to.
  93991. */
  93992. abstract camera: Camera;
  93993. /**
  93994. * Whether keyboard modifier keys are pressed at time of last mouse event.
  93995. */
  93996. protected _altKey: boolean;
  93997. protected _ctrlKey: boolean;
  93998. protected _metaKey: boolean;
  93999. protected _shiftKey: boolean;
  94000. /**
  94001. * Which mouse buttons were pressed at time of last mouse event.
  94002. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94003. */
  94004. protected _buttonsPressed: number;
  94005. /**
  94006. * Defines the buttons associated with the input to handle camera move.
  94007. */
  94008. buttons: number[];
  94009. /**
  94010. * Attach the input controls to a specific dom element to get the input from.
  94011. * @param element Defines the element the controls should be listened from
  94012. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94013. */
  94014. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94015. /**
  94016. * Detach the current controls from the specified dom element.
  94017. * @param element Defines the element to stop listening the inputs from
  94018. */
  94019. detachControl(element: Nullable<HTMLElement>): void;
  94020. /**
  94021. * Gets the class name of the current input.
  94022. * @returns the class name
  94023. */
  94024. getClassName(): string;
  94025. /**
  94026. * Get the friendly name associated with the input class.
  94027. * @returns the input friendly name
  94028. */
  94029. getSimpleName(): string;
  94030. /**
  94031. * Called on pointer POINTERDOUBLETAP event.
  94032. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94033. */
  94034. protected onDoubleTap(type: string): void;
  94035. /**
  94036. * Called on pointer POINTERMOVE event if only a single touch is active.
  94037. * Override this method to provide functionality.
  94038. */
  94039. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94040. /**
  94041. * Called on pointer POINTERMOVE event if multiple touches are active.
  94042. * Override this method to provide functionality.
  94043. */
  94044. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94045. /**
  94046. * Called on JS contextmenu event.
  94047. * Override this method to provide functionality.
  94048. */
  94049. protected onContextMenu(evt: PointerEvent): void;
  94050. /**
  94051. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94052. * press.
  94053. * Override this method to provide functionality.
  94054. */
  94055. protected onButtonDown(evt: PointerEvent): void;
  94056. /**
  94057. * Called each time a new POINTERUP event occurs. Ie, for each button
  94058. * release.
  94059. * Override this method to provide functionality.
  94060. */
  94061. protected onButtonUp(evt: PointerEvent): void;
  94062. /**
  94063. * Called when window becomes inactive.
  94064. * Override this method to provide functionality.
  94065. */
  94066. protected onLostFocus(): void;
  94067. private _pointerInput;
  94068. private _observer;
  94069. private _onLostFocus;
  94070. private pointA;
  94071. private pointB;
  94072. }
  94073. }
  94074. declare module BABYLON {
  94075. /**
  94076. * Manage the pointers inputs to control an arc rotate camera.
  94077. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94078. */
  94079. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94080. /**
  94081. * Defines the camera the input is attached to.
  94082. */
  94083. camera: ArcRotateCamera;
  94084. /**
  94085. * Gets the class name of the current input.
  94086. * @returns the class name
  94087. */
  94088. getClassName(): string;
  94089. /**
  94090. * Defines the buttons associated with the input to handle camera move.
  94091. */
  94092. buttons: number[];
  94093. /**
  94094. * Defines the pointer angular sensibility along the X axis or how fast is
  94095. * the camera rotating.
  94096. */
  94097. angularSensibilityX: number;
  94098. /**
  94099. * Defines the pointer angular sensibility along the Y axis or how fast is
  94100. * the camera rotating.
  94101. */
  94102. angularSensibilityY: number;
  94103. /**
  94104. * Defines the pointer pinch precision or how fast is the camera zooming.
  94105. */
  94106. pinchPrecision: number;
  94107. /**
  94108. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94109. * from 0.
  94110. * It defines the percentage of current camera.radius to use as delta when
  94111. * pinch zoom is used.
  94112. */
  94113. pinchDeltaPercentage: number;
  94114. /**
  94115. * Defines the pointer panning sensibility or how fast is the camera moving.
  94116. */
  94117. panningSensibility: number;
  94118. /**
  94119. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94120. */
  94121. multiTouchPanning: boolean;
  94122. /**
  94123. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94124. * zoom (pinch) through multitouch.
  94125. */
  94126. multiTouchPanAndZoom: boolean;
  94127. /**
  94128. * Revers pinch action direction.
  94129. */
  94130. pinchInwards: boolean;
  94131. private _isPanClick;
  94132. private _twoFingerActivityCount;
  94133. private _isPinching;
  94134. /**
  94135. * Called on pointer POINTERMOVE event if only a single touch is active.
  94136. */
  94137. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94138. /**
  94139. * Called on pointer POINTERDOUBLETAP event.
  94140. */
  94141. protected onDoubleTap(type: string): void;
  94142. /**
  94143. * Called on pointer POINTERMOVE event if multiple touches are active.
  94144. */
  94145. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94146. /**
  94147. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94148. * press.
  94149. */
  94150. protected onButtonDown(evt: PointerEvent): void;
  94151. /**
  94152. * Called each time a new POINTERUP event occurs. Ie, for each button
  94153. * release.
  94154. */
  94155. protected onButtonUp(evt: PointerEvent): void;
  94156. /**
  94157. * Called when window becomes inactive.
  94158. */
  94159. protected onLostFocus(): void;
  94160. }
  94161. }
  94162. declare module BABYLON {
  94163. /**
  94164. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94165. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94166. */
  94167. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94168. /**
  94169. * Defines the camera the input is attached to.
  94170. */
  94171. camera: ArcRotateCamera;
  94172. /**
  94173. * Defines the list of key codes associated with the up action (increase alpha)
  94174. */
  94175. keysUp: number[];
  94176. /**
  94177. * Defines the list of key codes associated with the down action (decrease alpha)
  94178. */
  94179. keysDown: number[];
  94180. /**
  94181. * Defines the list of key codes associated with the left action (increase beta)
  94182. */
  94183. keysLeft: number[];
  94184. /**
  94185. * Defines the list of key codes associated with the right action (decrease beta)
  94186. */
  94187. keysRight: number[];
  94188. /**
  94189. * Defines the list of key codes associated with the reset action.
  94190. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94191. */
  94192. keysReset: number[];
  94193. /**
  94194. * Defines the panning sensibility of the inputs.
  94195. * (How fast is the camera paning)
  94196. */
  94197. panningSensibility: number;
  94198. /**
  94199. * Defines the zooming sensibility of the inputs.
  94200. * (How fast is the camera zooming)
  94201. */
  94202. zoomingSensibility: number;
  94203. /**
  94204. * Defines wether maintaining the alt key down switch the movement mode from
  94205. * orientation to zoom.
  94206. */
  94207. useAltToZoom: boolean;
  94208. /**
  94209. * Rotation speed of the camera
  94210. */
  94211. angularSpeed: number;
  94212. private _keys;
  94213. private _ctrlPressed;
  94214. private _altPressed;
  94215. private _onCanvasBlurObserver;
  94216. private _onKeyboardObserver;
  94217. private _engine;
  94218. private _scene;
  94219. /**
  94220. * Attach the input controls to a specific dom element to get the input from.
  94221. * @param element Defines the element the controls should be listened from
  94222. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94223. */
  94224. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94225. /**
  94226. * Detach the current controls from the specified dom element.
  94227. * @param element Defines the element to stop listening the inputs from
  94228. */
  94229. detachControl(element: Nullable<HTMLElement>): void;
  94230. /**
  94231. * Update the current camera state depending on the inputs that have been used this frame.
  94232. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94233. */
  94234. checkInputs(): void;
  94235. /**
  94236. * Gets the class name of the current intput.
  94237. * @returns the class name
  94238. */
  94239. getClassName(): string;
  94240. /**
  94241. * Get the friendly name associated with the input class.
  94242. * @returns the input friendly name
  94243. */
  94244. getSimpleName(): string;
  94245. }
  94246. }
  94247. declare module BABYLON {
  94248. /**
  94249. * Manage the mouse wheel inputs to control an arc rotate camera.
  94250. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94251. */
  94252. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94253. /**
  94254. * Defines the camera the input is attached to.
  94255. */
  94256. camera: ArcRotateCamera;
  94257. /**
  94258. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94259. */
  94260. wheelPrecision: number;
  94261. /**
  94262. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94263. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94264. */
  94265. wheelDeltaPercentage: number;
  94266. private _wheel;
  94267. private _observer;
  94268. /**
  94269. * Attach the input controls to a specific dom element to get the input from.
  94270. * @param element Defines the element the controls should be listened from
  94271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94272. */
  94273. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94274. /**
  94275. * Detach the current controls from the specified dom element.
  94276. * @param element Defines the element to stop listening the inputs from
  94277. */
  94278. detachControl(element: Nullable<HTMLElement>): void;
  94279. /**
  94280. * Gets the class name of the current intput.
  94281. * @returns the class name
  94282. */
  94283. getClassName(): string;
  94284. /**
  94285. * Get the friendly name associated with the input class.
  94286. * @returns the input friendly name
  94287. */
  94288. getSimpleName(): string;
  94289. }
  94290. }
  94291. declare module BABYLON {
  94292. /**
  94293. * Default Inputs manager for the ArcRotateCamera.
  94294. * It groups all the default supported inputs for ease of use.
  94295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94296. */
  94297. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94298. /**
  94299. * Instantiates a new ArcRotateCameraInputsManager.
  94300. * @param camera Defines the camera the inputs belong to
  94301. */
  94302. constructor(camera: ArcRotateCamera);
  94303. /**
  94304. * Add mouse wheel input support to the input manager.
  94305. * @returns the current input manager
  94306. */
  94307. addMouseWheel(): ArcRotateCameraInputsManager;
  94308. /**
  94309. * Add pointers input support to the input manager.
  94310. * @returns the current input manager
  94311. */
  94312. addPointers(): ArcRotateCameraInputsManager;
  94313. /**
  94314. * Add keyboard input support to the input manager.
  94315. * @returns the current input manager
  94316. */
  94317. addKeyboard(): ArcRotateCameraInputsManager;
  94318. }
  94319. }
  94320. declare module BABYLON {
  94321. /**
  94322. * This represents an orbital type of camera.
  94323. *
  94324. * 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.
  94325. * 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.
  94326. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94327. */
  94328. export class ArcRotateCamera extends TargetCamera {
  94329. /**
  94330. * Defines the rotation angle of the camera along the longitudinal axis.
  94331. */
  94332. alpha: number;
  94333. /**
  94334. * Defines the rotation angle of the camera along the latitudinal axis.
  94335. */
  94336. beta: number;
  94337. /**
  94338. * Defines the radius of the camera from it s target point.
  94339. */
  94340. radius: number;
  94341. protected _target: Vector3;
  94342. protected _targetHost: Nullable<AbstractMesh>;
  94343. /**
  94344. * Defines the target point of the camera.
  94345. * The camera looks towards it form the radius distance.
  94346. */
  94347. target: Vector3;
  94348. /**
  94349. * Define the current local position of the camera in the scene
  94350. */
  94351. position: Vector3;
  94352. protected _upVector: Vector3;
  94353. protected _upToYMatrix: Matrix;
  94354. protected _YToUpMatrix: Matrix;
  94355. /**
  94356. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94357. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94358. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94359. */
  94360. upVector: Vector3;
  94361. /**
  94362. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94363. */
  94364. setMatUp(): void;
  94365. /**
  94366. * Current inertia value on the longitudinal axis.
  94367. * The bigger this number the longer it will take for the camera to stop.
  94368. */
  94369. inertialAlphaOffset: number;
  94370. /**
  94371. * Current inertia value on the latitudinal axis.
  94372. * The bigger this number the longer it will take for the camera to stop.
  94373. */
  94374. inertialBetaOffset: number;
  94375. /**
  94376. * Current inertia value on the radius axis.
  94377. * The bigger this number the longer it will take for the camera to stop.
  94378. */
  94379. inertialRadiusOffset: number;
  94380. /**
  94381. * Minimum allowed angle on the longitudinal axis.
  94382. * This can help limiting how the Camera is able to move in the scene.
  94383. */
  94384. lowerAlphaLimit: Nullable<number>;
  94385. /**
  94386. * Maximum allowed angle on the longitudinal axis.
  94387. * This can help limiting how the Camera is able to move in the scene.
  94388. */
  94389. upperAlphaLimit: Nullable<number>;
  94390. /**
  94391. * Minimum allowed angle on the latitudinal axis.
  94392. * This can help limiting how the Camera is able to move in the scene.
  94393. */
  94394. lowerBetaLimit: number;
  94395. /**
  94396. * Maximum allowed angle on the latitudinal axis.
  94397. * This can help limiting how the Camera is able to move in the scene.
  94398. */
  94399. upperBetaLimit: number;
  94400. /**
  94401. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94402. * This can help limiting how the Camera is able to move in the scene.
  94403. */
  94404. lowerRadiusLimit: Nullable<number>;
  94405. /**
  94406. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94407. * This can help limiting how the Camera is able to move in the scene.
  94408. */
  94409. upperRadiusLimit: Nullable<number>;
  94410. /**
  94411. * Defines the current inertia value used during panning of the camera along the X axis.
  94412. */
  94413. inertialPanningX: number;
  94414. /**
  94415. * Defines the current inertia value used during panning of the camera along the Y axis.
  94416. */
  94417. inertialPanningY: number;
  94418. /**
  94419. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94420. * Basically if your fingers moves away from more than this distance you will be considered
  94421. * in pinch mode.
  94422. */
  94423. pinchToPanMaxDistance: number;
  94424. /**
  94425. * Defines the maximum distance the camera can pan.
  94426. * This could help keeping the cammera always in your scene.
  94427. */
  94428. panningDistanceLimit: Nullable<number>;
  94429. /**
  94430. * Defines the target of the camera before paning.
  94431. */
  94432. panningOriginTarget: Vector3;
  94433. /**
  94434. * Defines the value of the inertia used during panning.
  94435. * 0 would mean stop inertia and one would mean no decelleration at all.
  94436. */
  94437. panningInertia: number;
  94438. /**
  94439. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94440. */
  94441. angularSensibilityX: number;
  94442. /**
  94443. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94444. */
  94445. angularSensibilityY: number;
  94446. /**
  94447. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94448. */
  94449. pinchPrecision: number;
  94450. /**
  94451. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94452. * It will be used instead of pinchDeltaPrecision if different from 0.
  94453. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94454. */
  94455. pinchDeltaPercentage: number;
  94456. /**
  94457. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94458. */
  94459. panningSensibility: number;
  94460. /**
  94461. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94462. */
  94463. keysUp: number[];
  94464. /**
  94465. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94466. */
  94467. keysDown: number[];
  94468. /**
  94469. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94470. */
  94471. keysLeft: number[];
  94472. /**
  94473. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94474. */
  94475. keysRight: number[];
  94476. /**
  94477. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94478. */
  94479. wheelPrecision: number;
  94480. /**
  94481. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94482. * It will be used instead of pinchDeltaPrecision if different from 0.
  94483. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94484. */
  94485. wheelDeltaPercentage: number;
  94486. /**
  94487. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94488. */
  94489. zoomOnFactor: number;
  94490. /**
  94491. * Defines a screen offset for the camera position.
  94492. */
  94493. targetScreenOffset: Vector2;
  94494. /**
  94495. * Allows the camera to be completely reversed.
  94496. * If false the camera can not arrive upside down.
  94497. */
  94498. allowUpsideDown: boolean;
  94499. /**
  94500. * Define if double tap/click is used to restore the previously saved state of the camera.
  94501. */
  94502. useInputToRestoreState: boolean;
  94503. /** @hidden */
  94504. _viewMatrix: Matrix;
  94505. /** @hidden */
  94506. _useCtrlForPanning: boolean;
  94507. /** @hidden */
  94508. _panningMouseButton: number;
  94509. /**
  94510. * Defines the input associated to the camera.
  94511. */
  94512. inputs: ArcRotateCameraInputsManager;
  94513. /** @hidden */
  94514. _reset: () => void;
  94515. /**
  94516. * Defines the allowed panning axis.
  94517. */
  94518. panningAxis: Vector3;
  94519. protected _localDirection: Vector3;
  94520. protected _transformedDirection: Vector3;
  94521. private _bouncingBehavior;
  94522. /**
  94523. * Gets the bouncing behavior of the camera if it has been enabled.
  94524. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94525. */
  94526. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94527. /**
  94528. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94529. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94530. */
  94531. useBouncingBehavior: boolean;
  94532. private _framingBehavior;
  94533. /**
  94534. * Gets the framing behavior of the camera if it has been enabled.
  94535. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94536. */
  94537. readonly framingBehavior: Nullable<FramingBehavior>;
  94538. /**
  94539. * Defines if the framing behavior of the camera is enabled on the camera.
  94540. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94541. */
  94542. useFramingBehavior: boolean;
  94543. private _autoRotationBehavior;
  94544. /**
  94545. * Gets the auto rotation behavior of the camera if it has been enabled.
  94546. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94547. */
  94548. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94549. /**
  94550. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94551. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94552. */
  94553. useAutoRotationBehavior: boolean;
  94554. /**
  94555. * Observable triggered when the mesh target has been changed on the camera.
  94556. */
  94557. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94558. /**
  94559. * Event raised when the camera is colliding with a mesh.
  94560. */
  94561. onCollide: (collidedMesh: AbstractMesh) => void;
  94562. /**
  94563. * Defines whether the camera should check collision with the objects oh the scene.
  94564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94565. */
  94566. checkCollisions: boolean;
  94567. /**
  94568. * Defines the collision radius of the camera.
  94569. * This simulates a sphere around the camera.
  94570. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94571. */
  94572. collisionRadius: Vector3;
  94573. protected _collider: Collider;
  94574. protected _previousPosition: Vector3;
  94575. protected _collisionVelocity: Vector3;
  94576. protected _newPosition: Vector3;
  94577. protected _previousAlpha: number;
  94578. protected _previousBeta: number;
  94579. protected _previousRadius: number;
  94580. protected _collisionTriggered: boolean;
  94581. protected _targetBoundingCenter: Nullable<Vector3>;
  94582. private _computationVector;
  94583. /**
  94584. * Instantiates a new ArcRotateCamera in a given scene
  94585. * @param name Defines the name of the camera
  94586. * @param alpha Defines the camera rotation along the logitudinal axis
  94587. * @param beta Defines the camera rotation along the latitudinal axis
  94588. * @param radius Defines the camera distance from its target
  94589. * @param target Defines the camera target
  94590. * @param scene Defines the scene the camera belongs to
  94591. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94592. */
  94593. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94594. /** @hidden */
  94595. _initCache(): void;
  94596. /** @hidden */
  94597. _updateCache(ignoreParentClass?: boolean): void;
  94598. protected _getTargetPosition(): Vector3;
  94599. private _storedAlpha;
  94600. private _storedBeta;
  94601. private _storedRadius;
  94602. private _storedTarget;
  94603. /**
  94604. * Stores the current state of the camera (alpha, beta, radius and target)
  94605. * @returns the camera itself
  94606. */
  94607. storeState(): Camera;
  94608. /**
  94609. * @hidden
  94610. * Restored camera state. You must call storeState() first
  94611. */
  94612. _restoreStateValues(): boolean;
  94613. /** @hidden */
  94614. _isSynchronizedViewMatrix(): boolean;
  94615. /**
  94616. * Attached controls to the current camera.
  94617. * @param element Defines the element the controls should be listened from
  94618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94619. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94620. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94621. */
  94622. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94623. /**
  94624. * Detach the current controls from the camera.
  94625. * The camera will stop reacting to inputs.
  94626. * @param element Defines the element to stop listening the inputs from
  94627. */
  94628. detachControl(element: HTMLElement): void;
  94629. /** @hidden */
  94630. _checkInputs(): void;
  94631. protected _checkLimits(): void;
  94632. /**
  94633. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94634. */
  94635. rebuildAnglesAndRadius(): void;
  94636. /**
  94637. * Use a position to define the current camera related information like aplha, beta and radius
  94638. * @param position Defines the position to set the camera at
  94639. */
  94640. setPosition(position: Vector3): void;
  94641. /**
  94642. * Defines the target the camera should look at.
  94643. * This will automatically adapt alpha beta and radius to fit within the new target.
  94644. * @param target Defines the new target as a Vector or a mesh
  94645. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94646. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94647. */
  94648. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94649. /** @hidden */
  94650. _getViewMatrix(): Matrix;
  94651. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94652. /**
  94653. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94654. * @param meshes Defines the mesh to zoom on
  94655. * @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)
  94656. */
  94657. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94658. /**
  94659. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94660. * The target will be changed but the radius
  94661. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94662. * @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)
  94663. */
  94664. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94665. min: Vector3;
  94666. max: Vector3;
  94667. distance: number;
  94668. }, doNotUpdateMaxZ?: boolean): void;
  94669. /**
  94670. * @override
  94671. * Override Camera.createRigCamera
  94672. */
  94673. createRigCamera(name: string, cameraIndex: number): Camera;
  94674. /**
  94675. * @hidden
  94676. * @override
  94677. * Override Camera._updateRigCameras
  94678. */
  94679. _updateRigCameras(): void;
  94680. /**
  94681. * Destroy the camera and release the current resources hold by it.
  94682. */
  94683. dispose(): void;
  94684. /**
  94685. * Gets the current object class name.
  94686. * @return the class name
  94687. */
  94688. getClassName(): string;
  94689. }
  94690. }
  94691. declare module BABYLON {
  94692. /**
  94693. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94694. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94695. */
  94696. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94697. /**
  94698. * Gets the name of the behavior.
  94699. */
  94700. readonly name: string;
  94701. private _zoomStopsAnimation;
  94702. private _idleRotationSpeed;
  94703. private _idleRotationWaitTime;
  94704. private _idleRotationSpinupTime;
  94705. /**
  94706. * Sets the flag that indicates if user zooming should stop animation.
  94707. */
  94708. /**
  94709. * Gets the flag that indicates if user zooming should stop animation.
  94710. */
  94711. zoomStopsAnimation: boolean;
  94712. /**
  94713. * Sets the default speed at which the camera rotates around the model.
  94714. */
  94715. /**
  94716. * Gets the default speed at which the camera rotates around the model.
  94717. */
  94718. idleRotationSpeed: number;
  94719. /**
  94720. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94721. */
  94722. /**
  94723. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94724. */
  94725. idleRotationWaitTime: number;
  94726. /**
  94727. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94728. */
  94729. /**
  94730. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94731. */
  94732. idleRotationSpinupTime: number;
  94733. /**
  94734. * Gets a value indicating if the camera is currently rotating because of this behavior
  94735. */
  94736. readonly rotationInProgress: boolean;
  94737. private _onPrePointerObservableObserver;
  94738. private _onAfterCheckInputsObserver;
  94739. private _attachedCamera;
  94740. private _isPointerDown;
  94741. private _lastFrameTime;
  94742. private _lastInteractionTime;
  94743. private _cameraRotationSpeed;
  94744. /**
  94745. * Initializes the behavior.
  94746. */
  94747. init(): void;
  94748. /**
  94749. * Attaches the behavior to its arc rotate camera.
  94750. * @param camera Defines the camera to attach the behavior to
  94751. */
  94752. attach(camera: ArcRotateCamera): void;
  94753. /**
  94754. * Detaches the behavior from its current arc rotate camera.
  94755. */
  94756. detach(): void;
  94757. /**
  94758. * Returns true if user is scrolling.
  94759. * @return true if user is scrolling.
  94760. */
  94761. private _userIsZooming;
  94762. private _lastFrameRadius;
  94763. private _shouldAnimationStopForInteraction;
  94764. /**
  94765. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94766. */
  94767. private _applyUserInteraction;
  94768. private _userIsMoving;
  94769. }
  94770. }
  94771. declare module BABYLON {
  94772. /**
  94773. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94774. */
  94775. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94776. private ui;
  94777. /**
  94778. * The name of the behavior
  94779. */
  94780. name: string;
  94781. /**
  94782. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94783. */
  94784. distanceAwayFromFace: number;
  94785. /**
  94786. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94787. */
  94788. distanceAwayFromBottomOfFace: number;
  94789. private _faceVectors;
  94790. private _target;
  94791. private _scene;
  94792. private _onRenderObserver;
  94793. private _tmpMatrix;
  94794. private _tmpVector;
  94795. /**
  94796. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94797. * @param ui The transform node that should be attched to the mesh
  94798. */
  94799. constructor(ui: TransformNode);
  94800. /**
  94801. * Initializes the behavior
  94802. */
  94803. init(): void;
  94804. private _closestFace;
  94805. private _zeroVector;
  94806. private _lookAtTmpMatrix;
  94807. private _lookAtToRef;
  94808. /**
  94809. * Attaches the AttachToBoxBehavior to the passed in mesh
  94810. * @param target The mesh that the specified node will be attached to
  94811. */
  94812. attach(target: Mesh): void;
  94813. /**
  94814. * Detaches the behavior from the mesh
  94815. */
  94816. detach(): void;
  94817. }
  94818. }
  94819. declare module BABYLON {
  94820. /**
  94821. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  94822. */
  94823. export class FadeInOutBehavior implements Behavior<Mesh> {
  94824. /**
  94825. * Time in milliseconds to delay before fading in (Default: 0)
  94826. */
  94827. delay: number;
  94828. /**
  94829. * Time in milliseconds for the mesh to fade in (Default: 300)
  94830. */
  94831. fadeInTime: number;
  94832. private _millisecondsPerFrame;
  94833. private _hovered;
  94834. private _hoverValue;
  94835. private _ownerNode;
  94836. /**
  94837. * Instatiates the FadeInOutBehavior
  94838. */
  94839. constructor();
  94840. /**
  94841. * The name of the behavior
  94842. */
  94843. readonly name: string;
  94844. /**
  94845. * Initializes the behavior
  94846. */
  94847. init(): void;
  94848. /**
  94849. * Attaches the fade behavior on the passed in mesh
  94850. * @param ownerNode The mesh that will be faded in/out once attached
  94851. */
  94852. attach(ownerNode: Mesh): void;
  94853. /**
  94854. * Detaches the behavior from the mesh
  94855. */
  94856. detach(): void;
  94857. /**
  94858. * Triggers the mesh to begin fading in or out
  94859. * @param value if the object should fade in or out (true to fade in)
  94860. */
  94861. fadeIn(value: boolean): void;
  94862. private _update;
  94863. private _setAllVisibility;
  94864. }
  94865. }
  94866. declare module BABYLON {
  94867. /**
  94868. * Class containing a set of static utilities functions for managing Pivots
  94869. * @hidden
  94870. */
  94871. export class PivotTools {
  94872. private static _PivotCached;
  94873. private static _OldPivotPoint;
  94874. private static _PivotTranslation;
  94875. private static _PivotTmpVector;
  94876. /** @hidden */
  94877. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  94878. /** @hidden */
  94879. static _RestorePivotPoint(mesh: AbstractMesh): void;
  94880. }
  94881. }
  94882. declare module BABYLON {
  94883. /**
  94884. * Class containing static functions to help procedurally build meshes
  94885. */
  94886. export class PlaneBuilder {
  94887. /**
  94888. * Creates a plane mesh
  94889. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  94890. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  94891. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  94892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  94893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  94894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  94895. * @param name defines the name of the mesh
  94896. * @param options defines the options used to create the mesh
  94897. * @param scene defines the hosting scene
  94898. * @returns the plane mesh
  94899. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  94900. */
  94901. static CreatePlane(name: string, options: {
  94902. size?: number;
  94903. width?: number;
  94904. height?: number;
  94905. sideOrientation?: number;
  94906. frontUVs?: Vector4;
  94907. backUVs?: Vector4;
  94908. updatable?: boolean;
  94909. sourcePlane?: Plane;
  94910. }, scene?: Nullable<Scene>): Mesh;
  94911. }
  94912. }
  94913. declare module BABYLON {
  94914. /**
  94915. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  94916. */
  94917. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  94918. private static _AnyMouseID;
  94919. private _attachedNode;
  94920. private _dragPlane;
  94921. private _scene;
  94922. private _pointerObserver;
  94923. private _beforeRenderObserver;
  94924. private static _planeScene;
  94925. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  94926. /**
  94927. * 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)
  94928. */
  94929. maxDragAngle: number;
  94930. /**
  94931. * @hidden
  94932. */
  94933. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  94934. /**
  94935. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  94936. */
  94937. currentDraggingPointerID: number;
  94938. /**
  94939. * The last position where the pointer hit the drag plane in world space
  94940. */
  94941. lastDragPosition: Vector3;
  94942. /**
  94943. * If the behavior is currently in a dragging state
  94944. */
  94945. dragging: boolean;
  94946. /**
  94947. * 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)
  94948. */
  94949. dragDeltaRatio: number;
  94950. /**
  94951. * If the drag plane orientation should be updated during the dragging (Default: true)
  94952. */
  94953. updateDragPlane: boolean;
  94954. private _debugMode;
  94955. private _moving;
  94956. /**
  94957. * Fires each time the attached mesh is dragged with the pointer
  94958. * * delta between last drag position and current drag position in world space
  94959. * * dragDistance along the drag axis
  94960. * * dragPlaneNormal normal of the current drag plane used during the drag
  94961. * * dragPlanePoint in world space where the drag intersects the drag plane
  94962. */
  94963. onDragObservable: Observable<{
  94964. delta: Vector3;
  94965. dragPlanePoint: Vector3;
  94966. dragPlaneNormal: Vector3;
  94967. dragDistance: number;
  94968. pointerId: number;
  94969. }>;
  94970. /**
  94971. * Fires each time a drag begins (eg. mouse down on mesh)
  94972. */
  94973. onDragStartObservable: Observable<{
  94974. dragPlanePoint: Vector3;
  94975. pointerId: number;
  94976. }>;
  94977. /**
  94978. * Fires each time a drag ends (eg. mouse release after drag)
  94979. */
  94980. onDragEndObservable: Observable<{
  94981. dragPlanePoint: Vector3;
  94982. pointerId: number;
  94983. }>;
  94984. /**
  94985. * If the attached mesh should be moved when dragged
  94986. */
  94987. moveAttached: boolean;
  94988. /**
  94989. * If the drag behavior will react to drag events (Default: true)
  94990. */
  94991. enabled: boolean;
  94992. /**
  94993. * If camera controls should be detached during the drag
  94994. */
  94995. detachCameraControls: boolean;
  94996. /**
  94997. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  94998. */
  94999. useObjectOrienationForDragging: boolean;
  95000. private _options;
  95001. /**
  95002. * Creates a pointer drag behavior that can be attached to a mesh
  95003. * @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)
  95004. */
  95005. constructor(options?: {
  95006. dragAxis?: Vector3;
  95007. dragPlaneNormal?: Vector3;
  95008. });
  95009. /**
  95010. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95011. */
  95012. validateDrag: (targetPosition: Vector3) => boolean;
  95013. /**
  95014. * The name of the behavior
  95015. */
  95016. readonly name: string;
  95017. /**
  95018. * Initializes the behavior
  95019. */
  95020. init(): void;
  95021. private _tmpVector;
  95022. private _alternatePickedPoint;
  95023. private _worldDragAxis;
  95024. private _targetPosition;
  95025. private _attachedElement;
  95026. /**
  95027. * Attaches the drag behavior the passed in mesh
  95028. * @param ownerNode The mesh that will be dragged around once attached
  95029. */
  95030. attach(ownerNode: AbstractMesh): void;
  95031. /**
  95032. * Force relase the drag action by code.
  95033. */
  95034. releaseDrag(): void;
  95035. private _startDragRay;
  95036. private _lastPointerRay;
  95037. /**
  95038. * Simulates the start of a pointer drag event on the behavior
  95039. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95040. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95041. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95042. */
  95043. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95044. private _startDrag;
  95045. private _dragDelta;
  95046. private _moveDrag;
  95047. private _pickWithRayOnDragPlane;
  95048. private _pointA;
  95049. private _pointB;
  95050. private _pointC;
  95051. private _lineA;
  95052. private _lineB;
  95053. private _localAxis;
  95054. private _lookAt;
  95055. private _updateDragPlanePosition;
  95056. /**
  95057. * Detaches the behavior from the mesh
  95058. */
  95059. detach(): void;
  95060. }
  95061. }
  95062. declare module BABYLON {
  95063. /**
  95064. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95065. */
  95066. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95067. private _dragBehaviorA;
  95068. private _dragBehaviorB;
  95069. private _startDistance;
  95070. private _initialScale;
  95071. private _targetScale;
  95072. private _ownerNode;
  95073. private _sceneRenderObserver;
  95074. /**
  95075. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95076. */
  95077. constructor();
  95078. /**
  95079. * The name of the behavior
  95080. */
  95081. readonly name: string;
  95082. /**
  95083. * Initializes the behavior
  95084. */
  95085. init(): void;
  95086. private _getCurrentDistance;
  95087. /**
  95088. * Attaches the scale behavior the passed in mesh
  95089. * @param ownerNode The mesh that will be scaled around once attached
  95090. */
  95091. attach(ownerNode: Mesh): void;
  95092. /**
  95093. * Detaches the behavior from the mesh
  95094. */
  95095. detach(): void;
  95096. }
  95097. }
  95098. declare module BABYLON {
  95099. /**
  95100. * 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
  95101. */
  95102. export class SixDofDragBehavior implements Behavior<Mesh> {
  95103. private static _virtualScene;
  95104. private _ownerNode;
  95105. private _sceneRenderObserver;
  95106. private _scene;
  95107. private _targetPosition;
  95108. private _virtualOriginMesh;
  95109. private _virtualDragMesh;
  95110. private _pointerObserver;
  95111. private _moving;
  95112. private _startingOrientation;
  95113. /**
  95114. * 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)
  95115. */
  95116. private zDragFactor;
  95117. /**
  95118. * If the object should rotate to face the drag origin
  95119. */
  95120. rotateDraggedObject: boolean;
  95121. /**
  95122. * If the behavior is currently in a dragging state
  95123. */
  95124. dragging: boolean;
  95125. /**
  95126. * 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)
  95127. */
  95128. dragDeltaRatio: number;
  95129. /**
  95130. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95131. */
  95132. currentDraggingPointerID: number;
  95133. /**
  95134. * If camera controls should be detached during the drag
  95135. */
  95136. detachCameraControls: boolean;
  95137. /**
  95138. * Fires each time a drag starts
  95139. */
  95140. onDragStartObservable: Observable<{}>;
  95141. /**
  95142. * Fires each time a drag ends (eg. mouse release after drag)
  95143. */
  95144. onDragEndObservable: Observable<{}>;
  95145. /**
  95146. * 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
  95147. */
  95148. constructor();
  95149. /**
  95150. * The name of the behavior
  95151. */
  95152. readonly name: string;
  95153. /**
  95154. * Initializes the behavior
  95155. */
  95156. init(): void;
  95157. /**
  95158. * Attaches the scale behavior the passed in mesh
  95159. * @param ownerNode The mesh that will be scaled around once attached
  95160. */
  95161. attach(ownerNode: Mesh): void;
  95162. /**
  95163. * Detaches the behavior from the mesh
  95164. */
  95165. detach(): void;
  95166. }
  95167. }
  95168. declare module BABYLON {
  95169. /**
  95170. * Class used to apply inverse kinematics to bones
  95171. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95172. */
  95173. export class BoneIKController {
  95174. private static _tmpVecs;
  95175. private static _tmpQuat;
  95176. private static _tmpMats;
  95177. /**
  95178. * Gets or sets the target mesh
  95179. */
  95180. targetMesh: AbstractMesh;
  95181. /** Gets or sets the mesh used as pole */
  95182. poleTargetMesh: AbstractMesh;
  95183. /**
  95184. * Gets or sets the bone used as pole
  95185. */
  95186. poleTargetBone: Nullable<Bone>;
  95187. /**
  95188. * Gets or sets the target position
  95189. */
  95190. targetPosition: Vector3;
  95191. /**
  95192. * Gets or sets the pole target position
  95193. */
  95194. poleTargetPosition: Vector3;
  95195. /**
  95196. * Gets or sets the pole target local offset
  95197. */
  95198. poleTargetLocalOffset: Vector3;
  95199. /**
  95200. * Gets or sets the pole angle
  95201. */
  95202. poleAngle: number;
  95203. /**
  95204. * Gets or sets the mesh associated with the controller
  95205. */
  95206. mesh: AbstractMesh;
  95207. /**
  95208. * 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)
  95209. */
  95210. slerpAmount: number;
  95211. private _bone1Quat;
  95212. private _bone1Mat;
  95213. private _bone2Ang;
  95214. private _bone1;
  95215. private _bone2;
  95216. private _bone1Length;
  95217. private _bone2Length;
  95218. private _maxAngle;
  95219. private _maxReach;
  95220. private _rightHandedSystem;
  95221. private _bendAxis;
  95222. private _slerping;
  95223. private _adjustRoll;
  95224. /**
  95225. * Gets or sets maximum allowed angle
  95226. */
  95227. maxAngle: number;
  95228. /**
  95229. * Creates a new BoneIKController
  95230. * @param mesh defines the mesh to control
  95231. * @param bone defines the bone to control
  95232. * @param options defines options to set up the controller
  95233. */
  95234. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95235. targetMesh?: AbstractMesh;
  95236. poleTargetMesh?: AbstractMesh;
  95237. poleTargetBone?: Bone;
  95238. poleTargetLocalOffset?: Vector3;
  95239. poleAngle?: number;
  95240. bendAxis?: Vector3;
  95241. maxAngle?: number;
  95242. slerpAmount?: number;
  95243. });
  95244. private _setMaxAngle;
  95245. /**
  95246. * Force the controller to update the bones
  95247. */
  95248. update(): void;
  95249. }
  95250. }
  95251. declare module BABYLON {
  95252. /**
  95253. * Class used to make a bone look toward a point in space
  95254. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95255. */
  95256. export class BoneLookController {
  95257. private static _tmpVecs;
  95258. private static _tmpQuat;
  95259. private static _tmpMats;
  95260. /**
  95261. * The target Vector3 that the bone will look at
  95262. */
  95263. target: Vector3;
  95264. /**
  95265. * The mesh that the bone is attached to
  95266. */
  95267. mesh: AbstractMesh;
  95268. /**
  95269. * The bone that will be looking to the target
  95270. */
  95271. bone: Bone;
  95272. /**
  95273. * The up axis of the coordinate system that is used when the bone is rotated
  95274. */
  95275. upAxis: Vector3;
  95276. /**
  95277. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95278. */
  95279. upAxisSpace: Space;
  95280. /**
  95281. * Used to make an adjustment to the yaw of the bone
  95282. */
  95283. adjustYaw: number;
  95284. /**
  95285. * Used to make an adjustment to the pitch of the bone
  95286. */
  95287. adjustPitch: number;
  95288. /**
  95289. * Used to make an adjustment to the roll of the bone
  95290. */
  95291. adjustRoll: number;
  95292. /**
  95293. * 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)
  95294. */
  95295. slerpAmount: number;
  95296. private _minYaw;
  95297. private _maxYaw;
  95298. private _minPitch;
  95299. private _maxPitch;
  95300. private _minYawSin;
  95301. private _minYawCos;
  95302. private _maxYawSin;
  95303. private _maxYawCos;
  95304. private _midYawConstraint;
  95305. private _minPitchTan;
  95306. private _maxPitchTan;
  95307. private _boneQuat;
  95308. private _slerping;
  95309. private _transformYawPitch;
  95310. private _transformYawPitchInv;
  95311. private _firstFrameSkipped;
  95312. private _yawRange;
  95313. private _fowardAxis;
  95314. /**
  95315. * Gets or sets the minimum yaw angle that the bone can look to
  95316. */
  95317. minYaw: number;
  95318. /**
  95319. * Gets or sets the maximum yaw angle that the bone can look to
  95320. */
  95321. maxYaw: number;
  95322. /**
  95323. * Gets or sets the minimum pitch angle that the bone can look to
  95324. */
  95325. minPitch: number;
  95326. /**
  95327. * Gets or sets the maximum pitch angle that the bone can look to
  95328. */
  95329. maxPitch: number;
  95330. /**
  95331. * Create a BoneLookController
  95332. * @param mesh the mesh that the bone belongs to
  95333. * @param bone the bone that will be looking to the target
  95334. * @param target the target Vector3 to look at
  95335. * @param options optional settings:
  95336. * * maxYaw: the maximum angle the bone will yaw to
  95337. * * minYaw: the minimum angle the bone will yaw to
  95338. * * maxPitch: the maximum angle the bone will pitch to
  95339. * * minPitch: the minimum angle the bone will yaw to
  95340. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95341. * * upAxis: the up axis of the coordinate system
  95342. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95343. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95344. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95345. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95346. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95347. * * adjustRoll: used to make an adjustment to the roll of the bone
  95348. **/
  95349. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95350. maxYaw?: number;
  95351. minYaw?: number;
  95352. maxPitch?: number;
  95353. minPitch?: number;
  95354. slerpAmount?: number;
  95355. upAxis?: Vector3;
  95356. upAxisSpace?: Space;
  95357. yawAxis?: Vector3;
  95358. pitchAxis?: Vector3;
  95359. adjustYaw?: number;
  95360. adjustPitch?: number;
  95361. adjustRoll?: number;
  95362. });
  95363. /**
  95364. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95365. */
  95366. update(): void;
  95367. private _getAngleDiff;
  95368. private _getAngleBetween;
  95369. private _isAngleBetween;
  95370. }
  95371. }
  95372. declare module BABYLON {
  95373. /**
  95374. * Manage the gamepad inputs to control an arc rotate camera.
  95375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95376. */
  95377. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95378. /**
  95379. * Defines the camera the input is attached to.
  95380. */
  95381. camera: ArcRotateCamera;
  95382. /**
  95383. * Defines the gamepad the input is gathering event from.
  95384. */
  95385. gamepad: Nullable<Gamepad>;
  95386. /**
  95387. * Defines the gamepad rotation sensiblity.
  95388. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95389. */
  95390. gamepadRotationSensibility: number;
  95391. /**
  95392. * Defines the gamepad move sensiblity.
  95393. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95394. */
  95395. gamepadMoveSensibility: number;
  95396. private _onGamepadConnectedObserver;
  95397. private _onGamepadDisconnectedObserver;
  95398. /**
  95399. * Attach the input controls to a specific dom element to get the input from.
  95400. * @param element Defines the element the controls should be listened from
  95401. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95402. */
  95403. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95404. /**
  95405. * Detach the current controls from the specified dom element.
  95406. * @param element Defines the element to stop listening the inputs from
  95407. */
  95408. detachControl(element: Nullable<HTMLElement>): void;
  95409. /**
  95410. * Update the current camera state depending on the inputs that have been used this frame.
  95411. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95412. */
  95413. checkInputs(): void;
  95414. /**
  95415. * Gets the class name of the current intput.
  95416. * @returns the class name
  95417. */
  95418. getClassName(): string;
  95419. /**
  95420. * Get the friendly name associated with the input class.
  95421. * @returns the input friendly name
  95422. */
  95423. getSimpleName(): string;
  95424. }
  95425. }
  95426. declare module BABYLON {
  95427. interface ArcRotateCameraInputsManager {
  95428. /**
  95429. * Add orientation input support to the input manager.
  95430. * @returns the current input manager
  95431. */
  95432. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95433. }
  95434. /**
  95435. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95437. */
  95438. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95439. /**
  95440. * Defines the camera the input is attached to.
  95441. */
  95442. camera: ArcRotateCamera;
  95443. /**
  95444. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95445. */
  95446. alphaCorrection: number;
  95447. /**
  95448. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95449. */
  95450. gammaCorrection: number;
  95451. private _alpha;
  95452. private _gamma;
  95453. private _dirty;
  95454. private _deviceOrientationHandler;
  95455. /**
  95456. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95457. */
  95458. constructor();
  95459. /**
  95460. * Attach the input controls to a specific dom element to get the input from.
  95461. * @param element Defines the element the controls should be listened from
  95462. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95463. */
  95464. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95465. /** @hidden */
  95466. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95467. /**
  95468. * Update the current camera state depending on the inputs that have been used this frame.
  95469. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95470. */
  95471. checkInputs(): void;
  95472. /**
  95473. * Detach the current controls from the specified dom element.
  95474. * @param element Defines the element to stop listening the inputs from
  95475. */
  95476. detachControl(element: Nullable<HTMLElement>): void;
  95477. /**
  95478. * Gets the class name of the current intput.
  95479. * @returns the class name
  95480. */
  95481. getClassName(): string;
  95482. /**
  95483. * Get the friendly name associated with the input class.
  95484. * @returns the input friendly name
  95485. */
  95486. getSimpleName(): string;
  95487. }
  95488. }
  95489. declare module BABYLON {
  95490. /**
  95491. * Listen to mouse events to control the camera.
  95492. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95493. */
  95494. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95495. /**
  95496. * Defines the camera the input is attached to.
  95497. */
  95498. camera: FlyCamera;
  95499. /**
  95500. * Defines if touch is enabled. (Default is true.)
  95501. */
  95502. touchEnabled: boolean;
  95503. /**
  95504. * Defines the buttons associated with the input to handle camera rotation.
  95505. */
  95506. buttons: number[];
  95507. /**
  95508. * Assign buttons for Yaw control.
  95509. */
  95510. buttonsYaw: number[];
  95511. /**
  95512. * Assign buttons for Pitch control.
  95513. */
  95514. buttonsPitch: number[];
  95515. /**
  95516. * Assign buttons for Roll control.
  95517. */
  95518. buttonsRoll: number[];
  95519. /**
  95520. * Detect if any button is being pressed while mouse is moved.
  95521. * -1 = Mouse locked.
  95522. * 0 = Left button.
  95523. * 1 = Middle Button.
  95524. * 2 = Right Button.
  95525. */
  95526. activeButton: number;
  95527. /**
  95528. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95529. * Higher values reduce its sensitivity.
  95530. */
  95531. angularSensibility: number;
  95532. private _mousemoveCallback;
  95533. private _observer;
  95534. private _rollObserver;
  95535. private previousPosition;
  95536. private noPreventDefault;
  95537. private element;
  95538. /**
  95539. * Listen to mouse events to control the camera.
  95540. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95541. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95542. */
  95543. constructor(touchEnabled?: boolean);
  95544. /**
  95545. * Attach the mouse control to the HTML DOM element.
  95546. * @param element Defines the element that listens to the input events.
  95547. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95548. */
  95549. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95550. /**
  95551. * Detach the current controls from the specified dom element.
  95552. * @param element Defines the element to stop listening the inputs from
  95553. */
  95554. detachControl(element: Nullable<HTMLElement>): void;
  95555. /**
  95556. * Gets the class name of the current input.
  95557. * @returns the class name.
  95558. */
  95559. getClassName(): string;
  95560. /**
  95561. * Get the friendly name associated with the input class.
  95562. * @returns the input's friendly name.
  95563. */
  95564. getSimpleName(): string;
  95565. private _pointerInput;
  95566. private _onMouseMove;
  95567. /**
  95568. * Rotate camera by mouse offset.
  95569. */
  95570. private rotateCamera;
  95571. }
  95572. }
  95573. declare module BABYLON {
  95574. /**
  95575. * Default Inputs manager for the FlyCamera.
  95576. * It groups all the default supported inputs for ease of use.
  95577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95578. */
  95579. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95580. /**
  95581. * Instantiates a new FlyCameraInputsManager.
  95582. * @param camera Defines the camera the inputs belong to.
  95583. */
  95584. constructor(camera: FlyCamera);
  95585. /**
  95586. * Add keyboard input support to the input manager.
  95587. * @returns the new FlyCameraKeyboardMoveInput().
  95588. */
  95589. addKeyboard(): FlyCameraInputsManager;
  95590. /**
  95591. * Add mouse input support to the input manager.
  95592. * @param touchEnabled Enable touch screen support.
  95593. * @returns the new FlyCameraMouseInput().
  95594. */
  95595. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95596. }
  95597. }
  95598. declare module BABYLON {
  95599. /**
  95600. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95601. * such as in a 3D Space Shooter or a Flight Simulator.
  95602. */
  95603. export class FlyCamera extends TargetCamera {
  95604. /**
  95605. * Define the collision ellipsoid of the camera.
  95606. * This is helpful for simulating a camera body, like a player's body.
  95607. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95608. */
  95609. ellipsoid: Vector3;
  95610. /**
  95611. * Define an offset for the position of the ellipsoid around the camera.
  95612. * This can be helpful if the camera is attached away from the player's body center,
  95613. * such as at its head.
  95614. */
  95615. ellipsoidOffset: Vector3;
  95616. /**
  95617. * Enable or disable collisions of the camera with the rest of the scene objects.
  95618. */
  95619. checkCollisions: boolean;
  95620. /**
  95621. * Enable or disable gravity on the camera.
  95622. */
  95623. applyGravity: boolean;
  95624. /**
  95625. * Define the current direction the camera is moving to.
  95626. */
  95627. cameraDirection: Vector3;
  95628. /**
  95629. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95630. * This overrides and empties cameraRotation.
  95631. */
  95632. rotationQuaternion: Quaternion;
  95633. /**
  95634. * Track Roll to maintain the wanted Rolling when looking around.
  95635. */
  95636. _trackRoll: number;
  95637. /**
  95638. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95639. */
  95640. rollCorrect: number;
  95641. /**
  95642. * Mimic a banked turn, Rolling the camera when Yawing.
  95643. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95644. */
  95645. bankedTurn: boolean;
  95646. /**
  95647. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95648. */
  95649. bankedTurnLimit: number;
  95650. /**
  95651. * Value of 0 disables the banked Roll.
  95652. * Value of 1 is equal to the Yaw angle in radians.
  95653. */
  95654. bankedTurnMultiplier: number;
  95655. /**
  95656. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95657. */
  95658. inputs: FlyCameraInputsManager;
  95659. /**
  95660. * Gets the input sensibility for mouse input.
  95661. * Higher values reduce sensitivity.
  95662. */
  95663. /**
  95664. * Sets the input sensibility for a mouse input.
  95665. * Higher values reduce sensitivity.
  95666. */
  95667. angularSensibility: number;
  95668. /**
  95669. * Get the keys for camera movement forward.
  95670. */
  95671. /**
  95672. * Set the keys for camera movement forward.
  95673. */
  95674. keysForward: number[];
  95675. /**
  95676. * Get the keys for camera movement backward.
  95677. */
  95678. keysBackward: number[];
  95679. /**
  95680. * Get the keys for camera movement up.
  95681. */
  95682. /**
  95683. * Set the keys for camera movement up.
  95684. */
  95685. keysUp: number[];
  95686. /**
  95687. * Get the keys for camera movement down.
  95688. */
  95689. /**
  95690. * Set the keys for camera movement down.
  95691. */
  95692. keysDown: number[];
  95693. /**
  95694. * Get the keys for camera movement left.
  95695. */
  95696. /**
  95697. * Set the keys for camera movement left.
  95698. */
  95699. keysLeft: number[];
  95700. /**
  95701. * Set the keys for camera movement right.
  95702. */
  95703. /**
  95704. * Set the keys for camera movement right.
  95705. */
  95706. keysRight: number[];
  95707. /**
  95708. * Event raised when the camera collides with a mesh in the scene.
  95709. */
  95710. onCollide: (collidedMesh: AbstractMesh) => void;
  95711. private _collider;
  95712. private _needMoveForGravity;
  95713. private _oldPosition;
  95714. private _diffPosition;
  95715. private _newPosition;
  95716. /** @hidden */
  95717. _localDirection: Vector3;
  95718. /** @hidden */
  95719. _transformedDirection: Vector3;
  95720. /**
  95721. * Instantiates a FlyCamera.
  95722. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95723. * such as in a 3D Space Shooter or a Flight Simulator.
  95724. * @param name Define the name of the camera in the scene.
  95725. * @param position Define the starting position of the camera in the scene.
  95726. * @param scene Define the scene the camera belongs to.
  95727. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95728. */
  95729. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95730. /**
  95731. * Attach a control to the HTML DOM element.
  95732. * @param element Defines the element that listens to the input events.
  95733. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95734. */
  95735. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95736. /**
  95737. * Detach a control from the HTML DOM element.
  95738. * The camera will stop reacting to that input.
  95739. * @param element Defines the element that listens to the input events.
  95740. */
  95741. detachControl(element: HTMLElement): void;
  95742. private _collisionMask;
  95743. /**
  95744. * Get the mask that the camera ignores in collision events.
  95745. */
  95746. /**
  95747. * Set the mask that the camera ignores in collision events.
  95748. */
  95749. collisionMask: number;
  95750. /** @hidden */
  95751. _collideWithWorld(displacement: Vector3): void;
  95752. /** @hidden */
  95753. private _onCollisionPositionChange;
  95754. /** @hidden */
  95755. _checkInputs(): void;
  95756. /** @hidden */
  95757. _decideIfNeedsToMove(): boolean;
  95758. /** @hidden */
  95759. _updatePosition(): void;
  95760. /**
  95761. * Restore the Roll to its target value at the rate specified.
  95762. * @param rate - Higher means slower restoring.
  95763. * @hidden
  95764. */
  95765. restoreRoll(rate: number): void;
  95766. /**
  95767. * Destroy the camera and release the current resources held by it.
  95768. */
  95769. dispose(): void;
  95770. /**
  95771. * Get the current object class name.
  95772. * @returns the class name.
  95773. */
  95774. getClassName(): string;
  95775. }
  95776. }
  95777. declare module BABYLON {
  95778. /**
  95779. * Listen to keyboard events to control the camera.
  95780. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95781. */
  95782. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95783. /**
  95784. * Defines the camera the input is attached to.
  95785. */
  95786. camera: FlyCamera;
  95787. /**
  95788. * The list of keyboard keys used to control the forward move of the camera.
  95789. */
  95790. keysForward: number[];
  95791. /**
  95792. * The list of keyboard keys used to control the backward move of the camera.
  95793. */
  95794. keysBackward: number[];
  95795. /**
  95796. * The list of keyboard keys used to control the forward move of the camera.
  95797. */
  95798. keysUp: number[];
  95799. /**
  95800. * The list of keyboard keys used to control the backward move of the camera.
  95801. */
  95802. keysDown: number[];
  95803. /**
  95804. * The list of keyboard keys used to control the right strafe move of the camera.
  95805. */
  95806. keysRight: number[];
  95807. /**
  95808. * The list of keyboard keys used to control the left strafe move of the camera.
  95809. */
  95810. keysLeft: number[];
  95811. private _keys;
  95812. private _onCanvasBlurObserver;
  95813. private _onKeyboardObserver;
  95814. private _engine;
  95815. private _scene;
  95816. /**
  95817. * Attach the input controls to a specific dom element to get the input from.
  95818. * @param element Defines the element the controls should be listened from
  95819. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95820. */
  95821. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95822. /**
  95823. * Detach the current controls from the specified dom element.
  95824. * @param element Defines the element to stop listening the inputs from
  95825. */
  95826. detachControl(element: Nullable<HTMLElement>): void;
  95827. /**
  95828. * Gets the class name of the current intput.
  95829. * @returns the class name
  95830. */
  95831. getClassName(): string;
  95832. /** @hidden */
  95833. _onLostFocus(e: FocusEvent): void;
  95834. /**
  95835. * Get the friendly name associated with the input class.
  95836. * @returns the input friendly name
  95837. */
  95838. getSimpleName(): string;
  95839. /**
  95840. * Update the current camera state depending on the inputs that have been used this frame.
  95841. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95842. */
  95843. checkInputs(): void;
  95844. }
  95845. }
  95846. declare module BABYLON {
  95847. /**
  95848. * Manage the mouse wheel inputs to control a follow camera.
  95849. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95850. */
  95851. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  95852. /**
  95853. * Defines the camera the input is attached to.
  95854. */
  95855. camera: FollowCamera;
  95856. /**
  95857. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  95858. */
  95859. axisControlRadius: boolean;
  95860. /**
  95861. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  95862. */
  95863. axisControlHeight: boolean;
  95864. /**
  95865. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  95866. */
  95867. axisControlRotation: boolean;
  95868. /**
  95869. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  95870. * relation to mouseWheel events.
  95871. */
  95872. wheelPrecision: number;
  95873. /**
  95874. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  95875. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  95876. */
  95877. wheelDeltaPercentage: number;
  95878. private _wheel;
  95879. private _observer;
  95880. /**
  95881. * Attach the input controls to a specific dom element to get the input from.
  95882. * @param element Defines the element the controls should be listened from
  95883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95884. */
  95885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95886. /**
  95887. * Detach the current controls from the specified dom element.
  95888. * @param element Defines the element to stop listening the inputs from
  95889. */
  95890. detachControl(element: Nullable<HTMLElement>): void;
  95891. /**
  95892. * Gets the class name of the current intput.
  95893. * @returns the class name
  95894. */
  95895. getClassName(): string;
  95896. /**
  95897. * Get the friendly name associated with the input class.
  95898. * @returns the input friendly name
  95899. */
  95900. getSimpleName(): string;
  95901. }
  95902. }
  95903. declare module BABYLON {
  95904. /**
  95905. * Manage the pointers inputs to control an follow camera.
  95906. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95907. */
  95908. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  95909. /**
  95910. * Defines the camera the input is attached to.
  95911. */
  95912. camera: FollowCamera;
  95913. /**
  95914. * Gets the class name of the current input.
  95915. * @returns the class name
  95916. */
  95917. getClassName(): string;
  95918. /**
  95919. * Defines the pointer angular sensibility along the X axis or how fast is
  95920. * the camera rotating.
  95921. * A negative number will reverse the axis direction.
  95922. */
  95923. angularSensibilityX: number;
  95924. /**
  95925. * Defines the pointer angular sensibility along the Y axis or how fast is
  95926. * the camera rotating.
  95927. * A negative number will reverse the axis direction.
  95928. */
  95929. angularSensibilityY: number;
  95930. /**
  95931. * Defines the pointer pinch precision or how fast is the camera zooming.
  95932. * A negative number will reverse the axis direction.
  95933. */
  95934. pinchPrecision: number;
  95935. /**
  95936. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  95937. * from 0.
  95938. * It defines the percentage of current camera.radius to use as delta when
  95939. * pinch zoom is used.
  95940. */
  95941. pinchDeltaPercentage: number;
  95942. /**
  95943. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  95944. */
  95945. axisXControlRadius: boolean;
  95946. /**
  95947. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  95948. */
  95949. axisXControlHeight: boolean;
  95950. /**
  95951. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  95952. */
  95953. axisXControlRotation: boolean;
  95954. /**
  95955. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  95956. */
  95957. axisYControlRadius: boolean;
  95958. /**
  95959. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  95960. */
  95961. axisYControlHeight: boolean;
  95962. /**
  95963. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  95964. */
  95965. axisYControlRotation: boolean;
  95966. /**
  95967. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  95968. */
  95969. axisPinchControlRadius: boolean;
  95970. /**
  95971. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  95972. */
  95973. axisPinchControlHeight: boolean;
  95974. /**
  95975. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  95976. */
  95977. axisPinchControlRotation: boolean;
  95978. /**
  95979. * Log error messages if basic misconfiguration has occurred.
  95980. */
  95981. warningEnable: boolean;
  95982. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  95983. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  95984. private _warningCounter;
  95985. private _warning;
  95986. }
  95987. }
  95988. declare module BABYLON {
  95989. /**
  95990. * Default Inputs manager for the FollowCamera.
  95991. * It groups all the default supported inputs for ease of use.
  95992. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95993. */
  95994. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  95995. /**
  95996. * Instantiates a new FollowCameraInputsManager.
  95997. * @param camera Defines the camera the inputs belong to
  95998. */
  95999. constructor(camera: FollowCamera);
  96000. /**
  96001. * Add keyboard input support to the input manager.
  96002. * @returns the current input manager
  96003. */
  96004. addKeyboard(): FollowCameraInputsManager;
  96005. /**
  96006. * Add mouse wheel input support to the input manager.
  96007. * @returns the current input manager
  96008. */
  96009. addMouseWheel(): FollowCameraInputsManager;
  96010. /**
  96011. * Add pointers input support to the input manager.
  96012. * @returns the current input manager
  96013. */
  96014. addPointers(): FollowCameraInputsManager;
  96015. /**
  96016. * Add orientation input support to the input manager.
  96017. * @returns the current input manager
  96018. */
  96019. addVRDeviceOrientation(): FollowCameraInputsManager;
  96020. }
  96021. }
  96022. declare module BABYLON {
  96023. /**
  96024. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96025. * an arc rotate version arcFollowCamera are available.
  96026. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96027. */
  96028. export class FollowCamera extends TargetCamera {
  96029. /**
  96030. * Distance the follow camera should follow an object at
  96031. */
  96032. radius: number;
  96033. /**
  96034. * Minimum allowed distance of the camera to the axis of rotation
  96035. * (The camera can not get closer).
  96036. * This can help limiting how the Camera is able to move in the scene.
  96037. */
  96038. lowerRadiusLimit: Nullable<number>;
  96039. /**
  96040. * Maximum allowed distance of the camera to the axis of rotation
  96041. * (The camera can not get further).
  96042. * This can help limiting how the Camera is able to move in the scene.
  96043. */
  96044. upperRadiusLimit: Nullable<number>;
  96045. /**
  96046. * Define a rotation offset between the camera and the object it follows
  96047. */
  96048. rotationOffset: number;
  96049. /**
  96050. * Minimum allowed angle to camera position relative to target object.
  96051. * This can help limiting how the Camera is able to move in the scene.
  96052. */
  96053. lowerRotationOffsetLimit: Nullable<number>;
  96054. /**
  96055. * Maximum allowed angle to camera position relative to target object.
  96056. * This can help limiting how the Camera is able to move in the scene.
  96057. */
  96058. upperRotationOffsetLimit: Nullable<number>;
  96059. /**
  96060. * Define a height offset between the camera and the object it follows.
  96061. * It can help following an object from the top (like a car chaing a plane)
  96062. */
  96063. heightOffset: number;
  96064. /**
  96065. * Minimum allowed height of camera position relative to target object.
  96066. * This can help limiting how the Camera is able to move in the scene.
  96067. */
  96068. lowerHeightOffsetLimit: Nullable<number>;
  96069. /**
  96070. * Maximum allowed height of camera position relative to target object.
  96071. * This can help limiting how the Camera is able to move in the scene.
  96072. */
  96073. upperHeightOffsetLimit: Nullable<number>;
  96074. /**
  96075. * Define how fast the camera can accelerate to follow it s target.
  96076. */
  96077. cameraAcceleration: number;
  96078. /**
  96079. * Define the speed limit of the camera following an object.
  96080. */
  96081. maxCameraSpeed: number;
  96082. /**
  96083. * Define the target of the camera.
  96084. */
  96085. lockedTarget: Nullable<AbstractMesh>;
  96086. /**
  96087. * Defines the input associated with the camera.
  96088. */
  96089. inputs: FollowCameraInputsManager;
  96090. /**
  96091. * Instantiates the follow camera.
  96092. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96093. * @param name Define the name of the camera in the scene
  96094. * @param position Define the position of the camera
  96095. * @param scene Define the scene the camera belong to
  96096. * @param lockedTarget Define the target of the camera
  96097. */
  96098. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96099. private _follow;
  96100. /**
  96101. * Attached controls to the current camera.
  96102. * @param element Defines the element the controls should be listened from
  96103. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96104. */
  96105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96106. /**
  96107. * Detach the current controls from the camera.
  96108. * The camera will stop reacting to inputs.
  96109. * @param element Defines the element to stop listening the inputs from
  96110. */
  96111. detachControl(element: HTMLElement): void;
  96112. /** @hidden */
  96113. _checkInputs(): void;
  96114. private _checkLimits;
  96115. /**
  96116. * Gets the camera class name.
  96117. * @returns the class name
  96118. */
  96119. getClassName(): string;
  96120. }
  96121. /**
  96122. * Arc Rotate version of the follow camera.
  96123. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96124. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96125. */
  96126. export class ArcFollowCamera extends TargetCamera {
  96127. /** The longitudinal angle of the camera */
  96128. alpha: number;
  96129. /** The latitudinal angle of the camera */
  96130. beta: number;
  96131. /** The radius of the camera from its target */
  96132. radius: number;
  96133. /** Define the camera target (the messh it should follow) */
  96134. target: Nullable<AbstractMesh>;
  96135. private _cartesianCoordinates;
  96136. /**
  96137. * Instantiates a new ArcFollowCamera
  96138. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96139. * @param name Define the name of the camera
  96140. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96141. * @param beta Define the rotation angle of the camera around the elevation axis
  96142. * @param radius Define the radius of the camera from its target point
  96143. * @param target Define the target of the camera
  96144. * @param scene Define the scene the camera belongs to
  96145. */
  96146. constructor(name: string,
  96147. /** The longitudinal angle of the camera */
  96148. alpha: number,
  96149. /** The latitudinal angle of the camera */
  96150. beta: number,
  96151. /** The radius of the camera from its target */
  96152. radius: number,
  96153. /** Define the camera target (the messh it should follow) */
  96154. target: Nullable<AbstractMesh>, scene: Scene);
  96155. private _follow;
  96156. /** @hidden */
  96157. _checkInputs(): void;
  96158. /**
  96159. * Returns the class name of the object.
  96160. * It is mostly used internally for serialization purposes.
  96161. */
  96162. getClassName(): string;
  96163. }
  96164. }
  96165. declare module BABYLON {
  96166. /**
  96167. * Manage the keyboard inputs to control the movement of a follow camera.
  96168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96169. */
  96170. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96171. /**
  96172. * Defines the camera the input is attached to.
  96173. */
  96174. camera: FollowCamera;
  96175. /**
  96176. * Defines the list of key codes associated with the up action (increase heightOffset)
  96177. */
  96178. keysHeightOffsetIncr: number[];
  96179. /**
  96180. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96181. */
  96182. keysHeightOffsetDecr: number[];
  96183. /**
  96184. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96185. */
  96186. keysHeightOffsetModifierAlt: boolean;
  96187. /**
  96188. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96189. */
  96190. keysHeightOffsetModifierCtrl: boolean;
  96191. /**
  96192. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96193. */
  96194. keysHeightOffsetModifierShift: boolean;
  96195. /**
  96196. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96197. */
  96198. keysRotationOffsetIncr: number[];
  96199. /**
  96200. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96201. */
  96202. keysRotationOffsetDecr: number[];
  96203. /**
  96204. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96205. */
  96206. keysRotationOffsetModifierAlt: boolean;
  96207. /**
  96208. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96209. */
  96210. keysRotationOffsetModifierCtrl: boolean;
  96211. /**
  96212. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96213. */
  96214. keysRotationOffsetModifierShift: boolean;
  96215. /**
  96216. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96217. */
  96218. keysRadiusIncr: number[];
  96219. /**
  96220. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96221. */
  96222. keysRadiusDecr: number[];
  96223. /**
  96224. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96225. */
  96226. keysRadiusModifierAlt: boolean;
  96227. /**
  96228. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96229. */
  96230. keysRadiusModifierCtrl: boolean;
  96231. /**
  96232. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96233. */
  96234. keysRadiusModifierShift: boolean;
  96235. /**
  96236. * Defines the rate of change of heightOffset.
  96237. */
  96238. heightSensibility: number;
  96239. /**
  96240. * Defines the rate of change of rotationOffset.
  96241. */
  96242. rotationSensibility: number;
  96243. /**
  96244. * Defines the rate of change of radius.
  96245. */
  96246. radiusSensibility: number;
  96247. private _keys;
  96248. private _ctrlPressed;
  96249. private _altPressed;
  96250. private _shiftPressed;
  96251. private _onCanvasBlurObserver;
  96252. private _onKeyboardObserver;
  96253. private _engine;
  96254. private _scene;
  96255. /**
  96256. * Attach the input controls to a specific dom element to get the input from.
  96257. * @param element Defines the element the controls should be listened from
  96258. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96259. */
  96260. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96261. /**
  96262. * Detach the current controls from the specified dom element.
  96263. * @param element Defines the element to stop listening the inputs from
  96264. */
  96265. detachControl(element: Nullable<HTMLElement>): void;
  96266. /**
  96267. * Update the current camera state depending on the inputs that have been used this frame.
  96268. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96269. */
  96270. checkInputs(): void;
  96271. /**
  96272. * Gets the class name of the current input.
  96273. * @returns the class name
  96274. */
  96275. getClassName(): string;
  96276. /**
  96277. * Get the friendly name associated with the input class.
  96278. * @returns the input friendly name
  96279. */
  96280. getSimpleName(): string;
  96281. /**
  96282. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96283. * allow modification of the heightOffset value.
  96284. */
  96285. private _modifierHeightOffset;
  96286. /**
  96287. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96288. * allow modification of the rotationOffset value.
  96289. */
  96290. private _modifierRotationOffset;
  96291. /**
  96292. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96293. * allow modification of the radius value.
  96294. */
  96295. private _modifierRadius;
  96296. }
  96297. }
  96298. declare module BABYLON {
  96299. interface FreeCameraInputsManager {
  96300. /**
  96301. * @hidden
  96302. */
  96303. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96304. /**
  96305. * Add orientation input support to the input manager.
  96306. * @returns the current input manager
  96307. */
  96308. addDeviceOrientation(): FreeCameraInputsManager;
  96309. }
  96310. /**
  96311. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96312. * Screen rotation is taken into account.
  96313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96314. */
  96315. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96316. private _camera;
  96317. private _screenOrientationAngle;
  96318. private _constantTranform;
  96319. private _screenQuaternion;
  96320. private _alpha;
  96321. private _beta;
  96322. private _gamma;
  96323. /**
  96324. * @hidden
  96325. */
  96326. _onDeviceOrientationChangedObservable: Observable<void>;
  96327. /**
  96328. * Instantiates a new input
  96329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96330. */
  96331. constructor();
  96332. /**
  96333. * Define the camera controlled by the input.
  96334. */
  96335. camera: FreeCamera;
  96336. /**
  96337. * Attach the input controls to a specific dom element to get the input from.
  96338. * @param element Defines the element the controls should be listened from
  96339. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96340. */
  96341. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96342. private _orientationChanged;
  96343. private _deviceOrientation;
  96344. /**
  96345. * Detach the current controls from the specified dom element.
  96346. * @param element Defines the element to stop listening the inputs from
  96347. */
  96348. detachControl(element: Nullable<HTMLElement>): void;
  96349. /**
  96350. * Update the current camera state depending on the inputs that have been used this frame.
  96351. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96352. */
  96353. checkInputs(): void;
  96354. /**
  96355. * Gets the class name of the current intput.
  96356. * @returns the class name
  96357. */
  96358. getClassName(): string;
  96359. /**
  96360. * Get the friendly name associated with the input class.
  96361. * @returns the input friendly name
  96362. */
  96363. getSimpleName(): string;
  96364. }
  96365. }
  96366. declare module BABYLON {
  96367. /**
  96368. * Manage the gamepad inputs to control a free camera.
  96369. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96370. */
  96371. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96372. /**
  96373. * Define the camera the input is attached to.
  96374. */
  96375. camera: FreeCamera;
  96376. /**
  96377. * Define the Gamepad controlling the input
  96378. */
  96379. gamepad: Nullable<Gamepad>;
  96380. /**
  96381. * Defines the gamepad rotation sensiblity.
  96382. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96383. */
  96384. gamepadAngularSensibility: number;
  96385. /**
  96386. * Defines the gamepad move sensiblity.
  96387. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96388. */
  96389. gamepadMoveSensibility: number;
  96390. private _onGamepadConnectedObserver;
  96391. private _onGamepadDisconnectedObserver;
  96392. private _cameraTransform;
  96393. private _deltaTransform;
  96394. private _vector3;
  96395. private _vector2;
  96396. /**
  96397. * Attach the input controls to a specific dom element to get the input from.
  96398. * @param element Defines the element the controls should be listened from
  96399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96400. */
  96401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96402. /**
  96403. * Detach the current controls from the specified dom element.
  96404. * @param element Defines the element to stop listening the inputs from
  96405. */
  96406. detachControl(element: Nullable<HTMLElement>): void;
  96407. /**
  96408. * Update the current camera state depending on the inputs that have been used this frame.
  96409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96410. */
  96411. checkInputs(): void;
  96412. /**
  96413. * Gets the class name of the current intput.
  96414. * @returns the class name
  96415. */
  96416. getClassName(): string;
  96417. /**
  96418. * Get the friendly name associated with the input class.
  96419. * @returns the input friendly name
  96420. */
  96421. getSimpleName(): string;
  96422. }
  96423. }
  96424. declare module BABYLON {
  96425. /**
  96426. * Defines the potential axis of a Joystick
  96427. */
  96428. export enum JoystickAxis {
  96429. /** X axis */
  96430. X = 0,
  96431. /** Y axis */
  96432. Y = 1,
  96433. /** Z axis */
  96434. Z = 2
  96435. }
  96436. /**
  96437. * Class used to define virtual joystick (used in touch mode)
  96438. */
  96439. export class VirtualJoystick {
  96440. /**
  96441. * Gets or sets a boolean indicating that left and right values must be inverted
  96442. */
  96443. reverseLeftRight: boolean;
  96444. /**
  96445. * Gets or sets a boolean indicating that up and down values must be inverted
  96446. */
  96447. reverseUpDown: boolean;
  96448. /**
  96449. * Gets the offset value for the position (ie. the change of the position value)
  96450. */
  96451. deltaPosition: Vector3;
  96452. /**
  96453. * Gets a boolean indicating if the virtual joystick was pressed
  96454. */
  96455. pressed: boolean;
  96456. /**
  96457. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96458. */
  96459. static Canvas: Nullable<HTMLCanvasElement>;
  96460. private static _globalJoystickIndex;
  96461. private static vjCanvasContext;
  96462. private static vjCanvasWidth;
  96463. private static vjCanvasHeight;
  96464. private static halfWidth;
  96465. private _action;
  96466. private _axisTargetedByLeftAndRight;
  96467. private _axisTargetedByUpAndDown;
  96468. private _joystickSensibility;
  96469. private _inversedSensibility;
  96470. private _joystickPointerID;
  96471. private _joystickColor;
  96472. private _joystickPointerPos;
  96473. private _joystickPreviousPointerPos;
  96474. private _joystickPointerStartPos;
  96475. private _deltaJoystickVector;
  96476. private _leftJoystick;
  96477. private _touches;
  96478. private _onPointerDownHandlerRef;
  96479. private _onPointerMoveHandlerRef;
  96480. private _onPointerUpHandlerRef;
  96481. private _onResize;
  96482. /**
  96483. * Creates a new virtual joystick
  96484. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96485. */
  96486. constructor(leftJoystick?: boolean);
  96487. /**
  96488. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96489. * @param newJoystickSensibility defines the new sensibility
  96490. */
  96491. setJoystickSensibility(newJoystickSensibility: number): void;
  96492. private _onPointerDown;
  96493. private _onPointerMove;
  96494. private _onPointerUp;
  96495. /**
  96496. * Change the color of the virtual joystick
  96497. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96498. */
  96499. setJoystickColor(newColor: string): void;
  96500. /**
  96501. * Defines a callback to call when the joystick is touched
  96502. * @param action defines the callback
  96503. */
  96504. setActionOnTouch(action: () => any): void;
  96505. /**
  96506. * Defines which axis you'd like to control for left & right
  96507. * @param axis defines the axis to use
  96508. */
  96509. setAxisForLeftRight(axis: JoystickAxis): void;
  96510. /**
  96511. * Defines which axis you'd like to control for up & down
  96512. * @param axis defines the axis to use
  96513. */
  96514. setAxisForUpDown(axis: JoystickAxis): void;
  96515. private _drawVirtualJoystick;
  96516. /**
  96517. * Release internal HTML canvas
  96518. */
  96519. releaseCanvas(): void;
  96520. }
  96521. }
  96522. declare module BABYLON {
  96523. interface FreeCameraInputsManager {
  96524. /**
  96525. * Add virtual joystick input support to the input manager.
  96526. * @returns the current input manager
  96527. */
  96528. addVirtualJoystick(): FreeCameraInputsManager;
  96529. }
  96530. /**
  96531. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96532. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96533. */
  96534. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96535. /**
  96536. * Defines the camera the input is attached to.
  96537. */
  96538. camera: FreeCamera;
  96539. private _leftjoystick;
  96540. private _rightjoystick;
  96541. /**
  96542. * Gets the left stick of the virtual joystick.
  96543. * @returns The virtual Joystick
  96544. */
  96545. getLeftJoystick(): VirtualJoystick;
  96546. /**
  96547. * Gets the right stick of the virtual joystick.
  96548. * @returns The virtual Joystick
  96549. */
  96550. getRightJoystick(): VirtualJoystick;
  96551. /**
  96552. * Update the current camera state depending on the inputs that have been used this frame.
  96553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96554. */
  96555. checkInputs(): void;
  96556. /**
  96557. * Attach the input controls to a specific dom element to get the input from.
  96558. * @param element Defines the element the controls should be listened from
  96559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96560. */
  96561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96562. /**
  96563. * Detach the current controls from the specified dom element.
  96564. * @param element Defines the element to stop listening the inputs from
  96565. */
  96566. detachControl(element: Nullable<HTMLElement>): void;
  96567. /**
  96568. * Gets the class name of the current intput.
  96569. * @returns the class name
  96570. */
  96571. getClassName(): string;
  96572. /**
  96573. * Get the friendly name associated with the input class.
  96574. * @returns the input friendly name
  96575. */
  96576. getSimpleName(): string;
  96577. }
  96578. }
  96579. declare module BABYLON {
  96580. /**
  96581. * This represents a FPS type of camera controlled by touch.
  96582. * This is like a universal camera minus the Gamepad controls.
  96583. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96584. */
  96585. export class TouchCamera extends FreeCamera {
  96586. /**
  96587. * Defines the touch sensibility for rotation.
  96588. * The higher the faster.
  96589. */
  96590. touchAngularSensibility: number;
  96591. /**
  96592. * Defines the touch sensibility for move.
  96593. * The higher the faster.
  96594. */
  96595. touchMoveSensibility: number;
  96596. /**
  96597. * Instantiates a new touch camera.
  96598. * This represents a FPS type of camera controlled by touch.
  96599. * This is like a universal camera minus the Gamepad controls.
  96600. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96601. * @param name Define the name of the camera in the scene
  96602. * @param position Define the start position of the camera in the scene
  96603. * @param scene Define the scene the camera belongs to
  96604. */
  96605. constructor(name: string, position: Vector3, scene: Scene);
  96606. /**
  96607. * Gets the current object class name.
  96608. * @return the class name
  96609. */
  96610. getClassName(): string;
  96611. /** @hidden */
  96612. _setupInputs(): void;
  96613. }
  96614. }
  96615. declare module BABYLON {
  96616. /**
  96617. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96618. * being tilted forward or back and left or right.
  96619. */
  96620. export class DeviceOrientationCamera extends FreeCamera {
  96621. private _initialQuaternion;
  96622. private _quaternionCache;
  96623. private _tmpDragQuaternion;
  96624. /**
  96625. * Creates a new device orientation camera
  96626. * @param name The name of the camera
  96627. * @param position The start position camera
  96628. * @param scene The scene the camera belongs to
  96629. */
  96630. constructor(name: string, position: Vector3, scene: Scene);
  96631. /**
  96632. * Disabled pointer input on first orientation sensor update (Default: true)
  96633. */
  96634. disablePointerInputWhenUsingDeviceOrientation: boolean;
  96635. private _dragFactor;
  96636. /**
  96637. * Enabled turning on the y axis when the orientation sensor is active
  96638. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96639. */
  96640. enableHorizontalDragging(dragFactor?: number): void;
  96641. /**
  96642. * Gets the current instance class name ("DeviceOrientationCamera").
  96643. * This helps avoiding instanceof at run time.
  96644. * @returns the class name
  96645. */
  96646. getClassName(): string;
  96647. /**
  96648. * @hidden
  96649. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96650. */
  96651. _checkInputs(): void;
  96652. /**
  96653. * Reset the camera to its default orientation on the specified axis only.
  96654. * @param axis The axis to reset
  96655. */
  96656. resetToCurrentRotation(axis?: Axis): void;
  96657. }
  96658. }
  96659. declare module BABYLON {
  96660. /**
  96661. * 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,
  96662. * which still works and will still be found in many Playgrounds.
  96663. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96664. */
  96665. export class UniversalCamera extends TouchCamera {
  96666. /**
  96667. * Defines the gamepad rotation sensiblity.
  96668. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96669. */
  96670. gamepadAngularSensibility: number;
  96671. /**
  96672. * Defines the gamepad move sensiblity.
  96673. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96674. */
  96675. gamepadMoveSensibility: number;
  96676. /**
  96677. * 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,
  96678. * which still works and will still be found in many Playgrounds.
  96679. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96680. * @param name Define the name of the camera in the scene
  96681. * @param position Define the start position of the camera in the scene
  96682. * @param scene Define the scene the camera belongs to
  96683. */
  96684. constructor(name: string, position: Vector3, scene: Scene);
  96685. /**
  96686. * Gets the current object class name.
  96687. * @return the class name
  96688. */
  96689. getClassName(): string;
  96690. }
  96691. }
  96692. declare module BABYLON {
  96693. /**
  96694. * This represents a FPS type of camera. This is only here for back compat purpose.
  96695. * Please use the UniversalCamera instead as both are identical.
  96696. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96697. */
  96698. export class GamepadCamera extends UniversalCamera {
  96699. /**
  96700. * Instantiates a new Gamepad Camera
  96701. * This represents a FPS type of camera. This is only here for back compat purpose.
  96702. * Please use the UniversalCamera instead as both are identical.
  96703. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96704. * @param name Define the name of the camera in the scene
  96705. * @param position Define the start position of the camera in the scene
  96706. * @param scene Define the scene the camera belongs to
  96707. */
  96708. constructor(name: string, position: Vector3, scene: Scene);
  96709. /**
  96710. * Gets the current object class name.
  96711. * @return the class name
  96712. */
  96713. getClassName(): string;
  96714. }
  96715. }
  96716. declare module BABYLON {
  96717. /** @hidden */
  96718. export var passPixelShader: {
  96719. name: string;
  96720. shader: string;
  96721. };
  96722. }
  96723. declare module BABYLON {
  96724. /** @hidden */
  96725. export var passCubePixelShader: {
  96726. name: string;
  96727. shader: string;
  96728. };
  96729. }
  96730. declare module BABYLON {
  96731. /**
  96732. * PassPostProcess which produces an output the same as it's input
  96733. */
  96734. export class PassPostProcess extends PostProcess {
  96735. /**
  96736. * Creates the PassPostProcess
  96737. * @param name The name of the effect.
  96738. * @param options The required width/height ratio to downsize to before computing the render pass.
  96739. * @param camera The camera to apply the render pass to.
  96740. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96741. * @param engine The engine which the post process will be applied. (default: current engine)
  96742. * @param reusable If the post process can be reused on the same frame. (default: false)
  96743. * @param textureType The type of texture to be used when performing the post processing.
  96744. * @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)
  96745. */
  96746. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96747. }
  96748. /**
  96749. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96750. */
  96751. export class PassCubePostProcess extends PostProcess {
  96752. private _face;
  96753. /**
  96754. * Gets or sets the cube face to display.
  96755. * * 0 is +X
  96756. * * 1 is -X
  96757. * * 2 is +Y
  96758. * * 3 is -Y
  96759. * * 4 is +Z
  96760. * * 5 is -Z
  96761. */
  96762. face: number;
  96763. /**
  96764. * Creates the PassCubePostProcess
  96765. * @param name The name of the effect.
  96766. * @param options The required width/height ratio to downsize to before computing the render pass.
  96767. * @param camera The camera to apply the render pass to.
  96768. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96769. * @param engine The engine which the post process will be applied. (default: current engine)
  96770. * @param reusable If the post process can be reused on the same frame. (default: false)
  96771. * @param textureType The type of texture to be used when performing the post processing.
  96772. * @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)
  96773. */
  96774. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96775. }
  96776. }
  96777. declare module BABYLON {
  96778. /** @hidden */
  96779. export var anaglyphPixelShader: {
  96780. name: string;
  96781. shader: string;
  96782. };
  96783. }
  96784. declare module BABYLON {
  96785. /**
  96786. * Postprocess used to generate anaglyphic rendering
  96787. */
  96788. export class AnaglyphPostProcess extends PostProcess {
  96789. private _passedProcess;
  96790. /**
  96791. * Creates a new AnaglyphPostProcess
  96792. * @param name defines postprocess name
  96793. * @param options defines creation options or target ratio scale
  96794. * @param rigCameras defines cameras using this postprocess
  96795. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96796. * @param engine defines hosting engine
  96797. * @param reusable defines if the postprocess will be reused multiple times per frame
  96798. */
  96799. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  96800. }
  96801. }
  96802. declare module BABYLON {
  96803. /**
  96804. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  96805. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96806. */
  96807. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  96808. /**
  96809. * Creates a new AnaglyphArcRotateCamera
  96810. * @param name defines camera name
  96811. * @param alpha defines alpha angle (in radians)
  96812. * @param beta defines beta angle (in radians)
  96813. * @param radius defines radius
  96814. * @param target defines camera target
  96815. * @param interaxialDistance defines distance between each color axis
  96816. * @param scene defines the hosting scene
  96817. */
  96818. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  96819. /**
  96820. * Gets camera class name
  96821. * @returns AnaglyphArcRotateCamera
  96822. */
  96823. getClassName(): string;
  96824. }
  96825. }
  96826. declare module BABYLON {
  96827. /**
  96828. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  96829. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96830. */
  96831. export class AnaglyphFreeCamera extends FreeCamera {
  96832. /**
  96833. * Creates a new AnaglyphFreeCamera
  96834. * @param name defines camera name
  96835. * @param position defines initial position
  96836. * @param interaxialDistance defines distance between each color axis
  96837. * @param scene defines the hosting scene
  96838. */
  96839. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96840. /**
  96841. * Gets camera class name
  96842. * @returns AnaglyphFreeCamera
  96843. */
  96844. getClassName(): string;
  96845. }
  96846. }
  96847. declare module BABYLON {
  96848. /**
  96849. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  96850. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96851. */
  96852. export class AnaglyphGamepadCamera extends GamepadCamera {
  96853. /**
  96854. * Creates a new AnaglyphGamepadCamera
  96855. * @param name defines camera name
  96856. * @param position defines initial position
  96857. * @param interaxialDistance defines distance between each color axis
  96858. * @param scene defines the hosting scene
  96859. */
  96860. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96861. /**
  96862. * Gets camera class name
  96863. * @returns AnaglyphGamepadCamera
  96864. */
  96865. getClassName(): string;
  96866. }
  96867. }
  96868. declare module BABYLON {
  96869. /**
  96870. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  96871. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  96872. */
  96873. export class AnaglyphUniversalCamera extends UniversalCamera {
  96874. /**
  96875. * Creates a new AnaglyphUniversalCamera
  96876. * @param name defines camera name
  96877. * @param position defines initial position
  96878. * @param interaxialDistance defines distance between each color axis
  96879. * @param scene defines the hosting scene
  96880. */
  96881. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  96882. /**
  96883. * Gets camera class name
  96884. * @returns AnaglyphUniversalCamera
  96885. */
  96886. getClassName(): string;
  96887. }
  96888. }
  96889. declare module BABYLON {
  96890. /** @hidden */
  96891. export var stereoscopicInterlacePixelShader: {
  96892. name: string;
  96893. shader: string;
  96894. };
  96895. }
  96896. declare module BABYLON {
  96897. /**
  96898. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  96899. */
  96900. export class StereoscopicInterlacePostProcess extends PostProcess {
  96901. private _stepSize;
  96902. private _passedProcess;
  96903. /**
  96904. * Initializes a StereoscopicInterlacePostProcess
  96905. * @param name The name of the effect.
  96906. * @param rigCameras The rig cameras to be appled to the post process
  96907. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  96908. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96909. * @param engine The engine which the post process will be applied. (default: current engine)
  96910. * @param reusable If the post process can be reused on the same frame. (default: false)
  96911. */
  96912. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  96913. }
  96914. }
  96915. declare module BABYLON {
  96916. /**
  96917. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  96918. * @see http://doc.babylonjs.com/features/cameras
  96919. */
  96920. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  96921. /**
  96922. * Creates a new StereoscopicArcRotateCamera
  96923. * @param name defines camera name
  96924. * @param alpha defines alpha angle (in radians)
  96925. * @param beta defines beta angle (in radians)
  96926. * @param radius defines radius
  96927. * @param target defines camera target
  96928. * @param interaxialDistance defines distance between each color axis
  96929. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96930. * @param scene defines the hosting scene
  96931. */
  96932. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96933. /**
  96934. * Gets camera class name
  96935. * @returns StereoscopicArcRotateCamera
  96936. */
  96937. getClassName(): string;
  96938. }
  96939. }
  96940. declare module BABYLON {
  96941. /**
  96942. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  96943. * @see http://doc.babylonjs.com/features/cameras
  96944. */
  96945. export class StereoscopicFreeCamera extends FreeCamera {
  96946. /**
  96947. * Creates a new StereoscopicFreeCamera
  96948. * @param name defines camera name
  96949. * @param position defines initial position
  96950. * @param interaxialDistance defines distance between each color axis
  96951. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96952. * @param scene defines the hosting scene
  96953. */
  96954. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96955. /**
  96956. * Gets camera class name
  96957. * @returns StereoscopicFreeCamera
  96958. */
  96959. getClassName(): string;
  96960. }
  96961. }
  96962. declare module BABYLON {
  96963. /**
  96964. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  96965. * @see http://doc.babylonjs.com/features/cameras
  96966. */
  96967. export class StereoscopicGamepadCamera extends GamepadCamera {
  96968. /**
  96969. * Creates a new StereoscopicGamepadCamera
  96970. * @param name defines camera name
  96971. * @param position defines initial position
  96972. * @param interaxialDistance defines distance between each color axis
  96973. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96974. * @param scene defines the hosting scene
  96975. */
  96976. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96977. /**
  96978. * Gets camera class name
  96979. * @returns StereoscopicGamepadCamera
  96980. */
  96981. getClassName(): string;
  96982. }
  96983. }
  96984. declare module BABYLON {
  96985. /**
  96986. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  96987. * @see http://doc.babylonjs.com/features/cameras
  96988. */
  96989. export class StereoscopicUniversalCamera extends UniversalCamera {
  96990. /**
  96991. * Creates a new StereoscopicUniversalCamera
  96992. * @param name defines camera name
  96993. * @param position defines initial position
  96994. * @param interaxialDistance defines distance between each color axis
  96995. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  96996. * @param scene defines the hosting scene
  96997. */
  96998. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  96999. /**
  97000. * Gets camera class name
  97001. * @returns StereoscopicUniversalCamera
  97002. */
  97003. getClassName(): string;
  97004. }
  97005. }
  97006. declare module BABYLON {
  97007. /**
  97008. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97009. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97010. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97011. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97012. */
  97013. export class VirtualJoysticksCamera extends FreeCamera {
  97014. /**
  97015. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97016. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97017. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97018. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97019. * @param name Define the name of the camera in the scene
  97020. * @param position Define the start position of the camera in the scene
  97021. * @param scene Define the scene the camera belongs to
  97022. */
  97023. constructor(name: string, position: Vector3, scene: Scene);
  97024. /**
  97025. * Gets the current object class name.
  97026. * @return the class name
  97027. */
  97028. getClassName(): string;
  97029. }
  97030. }
  97031. declare module BABYLON {
  97032. /**
  97033. * This represents all the required metrics to create a VR camera.
  97034. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97035. */
  97036. export class VRCameraMetrics {
  97037. /**
  97038. * Define the horizontal resolution off the screen.
  97039. */
  97040. hResolution: number;
  97041. /**
  97042. * Define the vertical resolution off the screen.
  97043. */
  97044. vResolution: number;
  97045. /**
  97046. * Define the horizontal screen size.
  97047. */
  97048. hScreenSize: number;
  97049. /**
  97050. * Define the vertical screen size.
  97051. */
  97052. vScreenSize: number;
  97053. /**
  97054. * Define the vertical screen center position.
  97055. */
  97056. vScreenCenter: number;
  97057. /**
  97058. * Define the distance of the eyes to the screen.
  97059. */
  97060. eyeToScreenDistance: number;
  97061. /**
  97062. * Define the distance between both lenses
  97063. */
  97064. lensSeparationDistance: number;
  97065. /**
  97066. * Define the distance between both viewer's eyes.
  97067. */
  97068. interpupillaryDistance: number;
  97069. /**
  97070. * Define the distortion factor of the VR postprocess.
  97071. * Please, touch with care.
  97072. */
  97073. distortionK: number[];
  97074. /**
  97075. * Define the chromatic aberration correction factors for the VR post process.
  97076. */
  97077. chromaAbCorrection: number[];
  97078. /**
  97079. * Define the scale factor of the post process.
  97080. * The smaller the better but the slower.
  97081. */
  97082. postProcessScaleFactor: number;
  97083. /**
  97084. * Define an offset for the lens center.
  97085. */
  97086. lensCenterOffset: number;
  97087. /**
  97088. * Define if the current vr camera should compensate the distortion of the lense or not.
  97089. */
  97090. compensateDistortion: boolean;
  97091. /**
  97092. * Defines if multiview should be enabled when rendering (Default: false)
  97093. */
  97094. multiviewEnabled: boolean;
  97095. /**
  97096. * Gets the rendering aspect ratio based on the provided resolutions.
  97097. */
  97098. readonly aspectRatio: number;
  97099. /**
  97100. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97101. */
  97102. readonly aspectRatioFov: number;
  97103. /**
  97104. * @hidden
  97105. */
  97106. readonly leftHMatrix: Matrix;
  97107. /**
  97108. * @hidden
  97109. */
  97110. readonly rightHMatrix: Matrix;
  97111. /**
  97112. * @hidden
  97113. */
  97114. readonly leftPreViewMatrix: Matrix;
  97115. /**
  97116. * @hidden
  97117. */
  97118. readonly rightPreViewMatrix: Matrix;
  97119. /**
  97120. * Get the default VRMetrics based on the most generic setup.
  97121. * @returns the default vr metrics
  97122. */
  97123. static GetDefault(): VRCameraMetrics;
  97124. }
  97125. }
  97126. declare module BABYLON {
  97127. /** @hidden */
  97128. export var vrDistortionCorrectionPixelShader: {
  97129. name: string;
  97130. shader: string;
  97131. };
  97132. }
  97133. declare module BABYLON {
  97134. /**
  97135. * VRDistortionCorrectionPostProcess used for mobile VR
  97136. */
  97137. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97138. private _isRightEye;
  97139. private _distortionFactors;
  97140. private _postProcessScaleFactor;
  97141. private _lensCenterOffset;
  97142. private _scaleIn;
  97143. private _scaleFactor;
  97144. private _lensCenter;
  97145. /**
  97146. * Initializes the VRDistortionCorrectionPostProcess
  97147. * @param name The name of the effect.
  97148. * @param camera The camera to apply the render pass to.
  97149. * @param isRightEye If this is for the right eye distortion
  97150. * @param vrMetrics All the required metrics for the VR camera
  97151. */
  97152. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97153. }
  97154. }
  97155. declare module BABYLON {
  97156. /**
  97157. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97158. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97159. */
  97160. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97161. /**
  97162. * Creates a new VRDeviceOrientationArcRotateCamera
  97163. * @param name defines camera name
  97164. * @param alpha defines the camera rotation along the logitudinal axis
  97165. * @param beta defines the camera rotation along the latitudinal axis
  97166. * @param radius defines the camera distance from its target
  97167. * @param target defines the camera target
  97168. * @param scene defines the scene the camera belongs to
  97169. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97170. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97171. */
  97172. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97173. /**
  97174. * Gets camera class name
  97175. * @returns VRDeviceOrientationArcRotateCamera
  97176. */
  97177. getClassName(): string;
  97178. }
  97179. }
  97180. declare module BABYLON {
  97181. /**
  97182. * Camera used to simulate VR rendering (based on FreeCamera)
  97183. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97184. */
  97185. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97186. /**
  97187. * Creates a new VRDeviceOrientationFreeCamera
  97188. * @param name defines camera name
  97189. * @param position defines the start position of the camera
  97190. * @param scene defines the scene the camera belongs to
  97191. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97192. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97193. */
  97194. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97195. /**
  97196. * Gets camera class name
  97197. * @returns VRDeviceOrientationFreeCamera
  97198. */
  97199. getClassName(): string;
  97200. }
  97201. }
  97202. declare module BABYLON {
  97203. /**
  97204. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97205. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97206. */
  97207. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97208. /**
  97209. * Creates a new VRDeviceOrientationGamepadCamera
  97210. * @param name defines camera name
  97211. * @param position defines the start position of the camera
  97212. * @param scene defines the scene the camera belongs to
  97213. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97214. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97215. */
  97216. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97217. /**
  97218. * Gets camera class name
  97219. * @returns VRDeviceOrientationGamepadCamera
  97220. */
  97221. getClassName(): string;
  97222. }
  97223. }
  97224. declare module BABYLON {
  97225. /**
  97226. * Defines supported buttons for XBox360 compatible gamepads
  97227. */
  97228. export enum Xbox360Button {
  97229. /** A */
  97230. A = 0,
  97231. /** B */
  97232. B = 1,
  97233. /** X */
  97234. X = 2,
  97235. /** Y */
  97236. Y = 3,
  97237. /** Start */
  97238. Start = 4,
  97239. /** Back */
  97240. Back = 5,
  97241. /** Left button */
  97242. LB = 6,
  97243. /** Right button */
  97244. RB = 7,
  97245. /** Left stick */
  97246. LeftStick = 8,
  97247. /** Right stick */
  97248. RightStick = 9
  97249. }
  97250. /** Defines values for XBox360 DPad */
  97251. export enum Xbox360Dpad {
  97252. /** Up */
  97253. Up = 0,
  97254. /** Down */
  97255. Down = 1,
  97256. /** Left */
  97257. Left = 2,
  97258. /** Right */
  97259. Right = 3
  97260. }
  97261. /**
  97262. * Defines a XBox360 gamepad
  97263. */
  97264. export class Xbox360Pad extends Gamepad {
  97265. private _leftTrigger;
  97266. private _rightTrigger;
  97267. private _onlefttriggerchanged;
  97268. private _onrighttriggerchanged;
  97269. private _onbuttondown;
  97270. private _onbuttonup;
  97271. private _ondpaddown;
  97272. private _ondpadup;
  97273. /** Observable raised when a button is pressed */
  97274. onButtonDownObservable: Observable<Xbox360Button>;
  97275. /** Observable raised when a button is released */
  97276. onButtonUpObservable: Observable<Xbox360Button>;
  97277. /** Observable raised when a pad is pressed */
  97278. onPadDownObservable: Observable<Xbox360Dpad>;
  97279. /** Observable raised when a pad is released */
  97280. onPadUpObservable: Observable<Xbox360Dpad>;
  97281. private _buttonA;
  97282. private _buttonB;
  97283. private _buttonX;
  97284. private _buttonY;
  97285. private _buttonBack;
  97286. private _buttonStart;
  97287. private _buttonLB;
  97288. private _buttonRB;
  97289. private _buttonLeftStick;
  97290. private _buttonRightStick;
  97291. private _dPadUp;
  97292. private _dPadDown;
  97293. private _dPadLeft;
  97294. private _dPadRight;
  97295. private _isXboxOnePad;
  97296. /**
  97297. * Creates a new XBox360 gamepad object
  97298. * @param id defines the id of this gamepad
  97299. * @param index defines its index
  97300. * @param gamepad defines the internal HTML gamepad object
  97301. * @param xboxOne defines if it is a XBox One gamepad
  97302. */
  97303. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97304. /**
  97305. * Defines the callback to call when left trigger is pressed
  97306. * @param callback defines the callback to use
  97307. */
  97308. onlefttriggerchanged(callback: (value: number) => void): void;
  97309. /**
  97310. * Defines the callback to call when right trigger is pressed
  97311. * @param callback defines the callback to use
  97312. */
  97313. onrighttriggerchanged(callback: (value: number) => void): void;
  97314. /**
  97315. * Gets the left trigger value
  97316. */
  97317. /**
  97318. * Sets the left trigger value
  97319. */
  97320. leftTrigger: number;
  97321. /**
  97322. * Gets the right trigger value
  97323. */
  97324. /**
  97325. * Sets the right trigger value
  97326. */
  97327. rightTrigger: number;
  97328. /**
  97329. * Defines the callback to call when a button is pressed
  97330. * @param callback defines the callback to use
  97331. */
  97332. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97333. /**
  97334. * Defines the callback to call when a button is released
  97335. * @param callback defines the callback to use
  97336. */
  97337. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97338. /**
  97339. * Defines the callback to call when a pad is pressed
  97340. * @param callback defines the callback to use
  97341. */
  97342. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97343. /**
  97344. * Defines the callback to call when a pad is released
  97345. * @param callback defines the callback to use
  97346. */
  97347. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97348. private _setButtonValue;
  97349. private _setDPadValue;
  97350. /**
  97351. * Gets the value of the `A` button
  97352. */
  97353. /**
  97354. * Sets the value of the `A` button
  97355. */
  97356. buttonA: number;
  97357. /**
  97358. * Gets the value of the `B` button
  97359. */
  97360. /**
  97361. * Sets the value of the `B` button
  97362. */
  97363. buttonB: number;
  97364. /**
  97365. * Gets the value of the `X` button
  97366. */
  97367. /**
  97368. * Sets the value of the `X` button
  97369. */
  97370. buttonX: number;
  97371. /**
  97372. * Gets the value of the `Y` button
  97373. */
  97374. /**
  97375. * Sets the value of the `Y` button
  97376. */
  97377. buttonY: number;
  97378. /**
  97379. * Gets the value of the `Start` button
  97380. */
  97381. /**
  97382. * Sets the value of the `Start` button
  97383. */
  97384. buttonStart: number;
  97385. /**
  97386. * Gets the value of the `Back` button
  97387. */
  97388. /**
  97389. * Sets the value of the `Back` button
  97390. */
  97391. buttonBack: number;
  97392. /**
  97393. * Gets the value of the `Left` button
  97394. */
  97395. /**
  97396. * Sets the value of the `Left` button
  97397. */
  97398. buttonLB: number;
  97399. /**
  97400. * Gets the value of the `Right` button
  97401. */
  97402. /**
  97403. * Sets the value of the `Right` button
  97404. */
  97405. buttonRB: number;
  97406. /**
  97407. * Gets the value of the Left joystick
  97408. */
  97409. /**
  97410. * Sets the value of the Left joystick
  97411. */
  97412. buttonLeftStick: number;
  97413. /**
  97414. * Gets the value of the Right joystick
  97415. */
  97416. /**
  97417. * Sets the value of the Right joystick
  97418. */
  97419. buttonRightStick: number;
  97420. /**
  97421. * Gets the value of D-pad up
  97422. */
  97423. /**
  97424. * Sets the value of D-pad up
  97425. */
  97426. dPadUp: number;
  97427. /**
  97428. * Gets the value of D-pad down
  97429. */
  97430. /**
  97431. * Sets the value of D-pad down
  97432. */
  97433. dPadDown: number;
  97434. /**
  97435. * Gets the value of D-pad left
  97436. */
  97437. /**
  97438. * Sets the value of D-pad left
  97439. */
  97440. dPadLeft: number;
  97441. /**
  97442. * Gets the value of D-pad right
  97443. */
  97444. /**
  97445. * Sets the value of D-pad right
  97446. */
  97447. dPadRight: number;
  97448. /**
  97449. * Force the gamepad to synchronize with device values
  97450. */
  97451. update(): void;
  97452. /**
  97453. * Disposes the gamepad
  97454. */
  97455. dispose(): void;
  97456. }
  97457. }
  97458. declare module BABYLON {
  97459. /**
  97460. * Base class of materials working in push mode in babylon JS
  97461. * @hidden
  97462. */
  97463. export class PushMaterial extends Material {
  97464. protected _activeEffect: Effect;
  97465. protected _normalMatrix: Matrix;
  97466. /**
  97467. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97468. * This means that the material can keep using a previous shader while a new one is being compiled.
  97469. * This is mostly used when shader parallel compilation is supported (true by default)
  97470. */
  97471. allowShaderHotSwapping: boolean;
  97472. constructor(name: string, scene: Scene);
  97473. getEffect(): Effect;
  97474. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97475. /**
  97476. * Binds the given world matrix to the active effect
  97477. *
  97478. * @param world the matrix to bind
  97479. */
  97480. bindOnlyWorldMatrix(world: Matrix): void;
  97481. /**
  97482. * Binds the given normal matrix to the active effect
  97483. *
  97484. * @param normalMatrix the matrix to bind
  97485. */
  97486. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97487. bind(world: Matrix, mesh?: Mesh): void;
  97488. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97489. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97490. }
  97491. }
  97492. declare module BABYLON {
  97493. /**
  97494. * This groups all the flags used to control the materials channel.
  97495. */
  97496. export class MaterialFlags {
  97497. private static _DiffuseTextureEnabled;
  97498. /**
  97499. * Are diffuse textures enabled in the application.
  97500. */
  97501. static DiffuseTextureEnabled: boolean;
  97502. private static _AmbientTextureEnabled;
  97503. /**
  97504. * Are ambient textures enabled in the application.
  97505. */
  97506. static AmbientTextureEnabled: boolean;
  97507. private static _OpacityTextureEnabled;
  97508. /**
  97509. * Are opacity textures enabled in the application.
  97510. */
  97511. static OpacityTextureEnabled: boolean;
  97512. private static _ReflectionTextureEnabled;
  97513. /**
  97514. * Are reflection textures enabled in the application.
  97515. */
  97516. static ReflectionTextureEnabled: boolean;
  97517. private static _EmissiveTextureEnabled;
  97518. /**
  97519. * Are emissive textures enabled in the application.
  97520. */
  97521. static EmissiveTextureEnabled: boolean;
  97522. private static _SpecularTextureEnabled;
  97523. /**
  97524. * Are specular textures enabled in the application.
  97525. */
  97526. static SpecularTextureEnabled: boolean;
  97527. private static _BumpTextureEnabled;
  97528. /**
  97529. * Are bump textures enabled in the application.
  97530. */
  97531. static BumpTextureEnabled: boolean;
  97532. private static _LightmapTextureEnabled;
  97533. /**
  97534. * Are lightmap textures enabled in the application.
  97535. */
  97536. static LightmapTextureEnabled: boolean;
  97537. private static _RefractionTextureEnabled;
  97538. /**
  97539. * Are refraction textures enabled in the application.
  97540. */
  97541. static RefractionTextureEnabled: boolean;
  97542. private static _ColorGradingTextureEnabled;
  97543. /**
  97544. * Are color grading textures enabled in the application.
  97545. */
  97546. static ColorGradingTextureEnabled: boolean;
  97547. private static _FresnelEnabled;
  97548. /**
  97549. * Are fresnels enabled in the application.
  97550. */
  97551. static FresnelEnabled: boolean;
  97552. private static _ClearCoatTextureEnabled;
  97553. /**
  97554. * Are clear coat textures enabled in the application.
  97555. */
  97556. static ClearCoatTextureEnabled: boolean;
  97557. private static _ClearCoatBumpTextureEnabled;
  97558. /**
  97559. * Are clear coat bump textures enabled in the application.
  97560. */
  97561. static ClearCoatBumpTextureEnabled: boolean;
  97562. private static _ClearCoatTintTextureEnabled;
  97563. /**
  97564. * Are clear coat tint textures enabled in the application.
  97565. */
  97566. static ClearCoatTintTextureEnabled: boolean;
  97567. private static _SheenTextureEnabled;
  97568. /**
  97569. * Are sheen textures enabled in the application.
  97570. */
  97571. static SheenTextureEnabled: boolean;
  97572. private static _AnisotropicTextureEnabled;
  97573. /**
  97574. * Are anisotropic textures enabled in the application.
  97575. */
  97576. static AnisotropicTextureEnabled: boolean;
  97577. private static _ThicknessTextureEnabled;
  97578. /**
  97579. * Are thickness textures enabled in the application.
  97580. */
  97581. static ThicknessTextureEnabled: boolean;
  97582. }
  97583. }
  97584. declare module BABYLON {
  97585. /** @hidden */
  97586. export var defaultFragmentDeclaration: {
  97587. name: string;
  97588. shader: string;
  97589. };
  97590. }
  97591. declare module BABYLON {
  97592. /** @hidden */
  97593. export var defaultUboDeclaration: {
  97594. name: string;
  97595. shader: string;
  97596. };
  97597. }
  97598. declare module BABYLON {
  97599. /** @hidden */
  97600. export var lightFragmentDeclaration: {
  97601. name: string;
  97602. shader: string;
  97603. };
  97604. }
  97605. declare module BABYLON {
  97606. /** @hidden */
  97607. export var lightUboDeclaration: {
  97608. name: string;
  97609. shader: string;
  97610. };
  97611. }
  97612. declare module BABYLON {
  97613. /** @hidden */
  97614. export var lightsFragmentFunctions: {
  97615. name: string;
  97616. shader: string;
  97617. };
  97618. }
  97619. declare module BABYLON {
  97620. /** @hidden */
  97621. export var shadowsFragmentFunctions: {
  97622. name: string;
  97623. shader: string;
  97624. };
  97625. }
  97626. declare module BABYLON {
  97627. /** @hidden */
  97628. export var fresnelFunction: {
  97629. name: string;
  97630. shader: string;
  97631. };
  97632. }
  97633. declare module BABYLON {
  97634. /** @hidden */
  97635. export var reflectionFunction: {
  97636. name: string;
  97637. shader: string;
  97638. };
  97639. }
  97640. declare module BABYLON {
  97641. /** @hidden */
  97642. export var bumpFragmentFunctions: {
  97643. name: string;
  97644. shader: string;
  97645. };
  97646. }
  97647. declare module BABYLON {
  97648. /** @hidden */
  97649. export var logDepthDeclaration: {
  97650. name: string;
  97651. shader: string;
  97652. };
  97653. }
  97654. declare module BABYLON {
  97655. /** @hidden */
  97656. export var bumpFragment: {
  97657. name: string;
  97658. shader: string;
  97659. };
  97660. }
  97661. declare module BABYLON {
  97662. /** @hidden */
  97663. export var depthPrePass: {
  97664. name: string;
  97665. shader: string;
  97666. };
  97667. }
  97668. declare module BABYLON {
  97669. /** @hidden */
  97670. export var lightFragment: {
  97671. name: string;
  97672. shader: string;
  97673. };
  97674. }
  97675. declare module BABYLON {
  97676. /** @hidden */
  97677. export var logDepthFragment: {
  97678. name: string;
  97679. shader: string;
  97680. };
  97681. }
  97682. declare module BABYLON {
  97683. /** @hidden */
  97684. export var defaultPixelShader: {
  97685. name: string;
  97686. shader: string;
  97687. };
  97688. }
  97689. declare module BABYLON {
  97690. /** @hidden */
  97691. export var defaultVertexDeclaration: {
  97692. name: string;
  97693. shader: string;
  97694. };
  97695. }
  97696. declare module BABYLON {
  97697. /** @hidden */
  97698. export var bumpVertexDeclaration: {
  97699. name: string;
  97700. shader: string;
  97701. };
  97702. }
  97703. declare module BABYLON {
  97704. /** @hidden */
  97705. export var bumpVertex: {
  97706. name: string;
  97707. shader: string;
  97708. };
  97709. }
  97710. declare module BABYLON {
  97711. /** @hidden */
  97712. export var fogVertex: {
  97713. name: string;
  97714. shader: string;
  97715. };
  97716. }
  97717. declare module BABYLON {
  97718. /** @hidden */
  97719. export var shadowsVertex: {
  97720. name: string;
  97721. shader: string;
  97722. };
  97723. }
  97724. declare module BABYLON {
  97725. /** @hidden */
  97726. export var pointCloudVertex: {
  97727. name: string;
  97728. shader: string;
  97729. };
  97730. }
  97731. declare module BABYLON {
  97732. /** @hidden */
  97733. export var logDepthVertex: {
  97734. name: string;
  97735. shader: string;
  97736. };
  97737. }
  97738. declare module BABYLON {
  97739. /** @hidden */
  97740. export var defaultVertexShader: {
  97741. name: string;
  97742. shader: string;
  97743. };
  97744. }
  97745. declare module BABYLON {
  97746. /** @hidden */
  97747. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97748. MAINUV1: boolean;
  97749. MAINUV2: boolean;
  97750. DIFFUSE: boolean;
  97751. DIFFUSEDIRECTUV: number;
  97752. AMBIENT: boolean;
  97753. AMBIENTDIRECTUV: number;
  97754. OPACITY: boolean;
  97755. OPACITYDIRECTUV: number;
  97756. OPACITYRGB: boolean;
  97757. REFLECTION: boolean;
  97758. EMISSIVE: boolean;
  97759. EMISSIVEDIRECTUV: number;
  97760. SPECULAR: boolean;
  97761. SPECULARDIRECTUV: number;
  97762. BUMP: boolean;
  97763. BUMPDIRECTUV: number;
  97764. PARALLAX: boolean;
  97765. PARALLAXOCCLUSION: boolean;
  97766. SPECULAROVERALPHA: boolean;
  97767. CLIPPLANE: boolean;
  97768. CLIPPLANE2: boolean;
  97769. CLIPPLANE3: boolean;
  97770. CLIPPLANE4: boolean;
  97771. ALPHATEST: boolean;
  97772. DEPTHPREPASS: boolean;
  97773. ALPHAFROMDIFFUSE: boolean;
  97774. POINTSIZE: boolean;
  97775. FOG: boolean;
  97776. SPECULARTERM: boolean;
  97777. DIFFUSEFRESNEL: boolean;
  97778. OPACITYFRESNEL: boolean;
  97779. REFLECTIONFRESNEL: boolean;
  97780. REFRACTIONFRESNEL: boolean;
  97781. EMISSIVEFRESNEL: boolean;
  97782. FRESNEL: boolean;
  97783. NORMAL: boolean;
  97784. UV1: boolean;
  97785. UV2: boolean;
  97786. VERTEXCOLOR: boolean;
  97787. VERTEXALPHA: boolean;
  97788. NUM_BONE_INFLUENCERS: number;
  97789. BonesPerMesh: number;
  97790. BONETEXTURE: boolean;
  97791. INSTANCES: boolean;
  97792. GLOSSINESS: boolean;
  97793. ROUGHNESS: boolean;
  97794. EMISSIVEASILLUMINATION: boolean;
  97795. LINKEMISSIVEWITHDIFFUSE: boolean;
  97796. REFLECTIONFRESNELFROMSPECULAR: boolean;
  97797. LIGHTMAP: boolean;
  97798. LIGHTMAPDIRECTUV: number;
  97799. OBJECTSPACE_NORMALMAP: boolean;
  97800. USELIGHTMAPASSHADOWMAP: boolean;
  97801. REFLECTIONMAP_3D: boolean;
  97802. REFLECTIONMAP_SPHERICAL: boolean;
  97803. REFLECTIONMAP_PLANAR: boolean;
  97804. REFLECTIONMAP_CUBIC: boolean;
  97805. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  97806. REFLECTIONMAP_PROJECTION: boolean;
  97807. REFLECTIONMAP_SKYBOX: boolean;
  97808. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  97809. REFLECTIONMAP_EXPLICIT: boolean;
  97810. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  97811. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  97812. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  97813. INVERTCUBICMAP: boolean;
  97814. LOGARITHMICDEPTH: boolean;
  97815. REFRACTION: boolean;
  97816. REFRACTIONMAP_3D: boolean;
  97817. REFLECTIONOVERALPHA: boolean;
  97818. TWOSIDEDLIGHTING: boolean;
  97819. SHADOWFLOAT: boolean;
  97820. MORPHTARGETS: boolean;
  97821. MORPHTARGETS_NORMAL: boolean;
  97822. MORPHTARGETS_TANGENT: boolean;
  97823. NUM_MORPH_INFLUENCERS: number;
  97824. NONUNIFORMSCALING: boolean;
  97825. PREMULTIPLYALPHA: boolean;
  97826. IMAGEPROCESSING: boolean;
  97827. VIGNETTE: boolean;
  97828. VIGNETTEBLENDMODEMULTIPLY: boolean;
  97829. VIGNETTEBLENDMODEOPAQUE: boolean;
  97830. TONEMAPPING: boolean;
  97831. TONEMAPPING_ACES: boolean;
  97832. CONTRAST: boolean;
  97833. COLORCURVES: boolean;
  97834. COLORGRADING: boolean;
  97835. COLORGRADING3D: boolean;
  97836. SAMPLER3DGREENDEPTH: boolean;
  97837. SAMPLER3DBGRMAP: boolean;
  97838. IMAGEPROCESSINGPOSTPROCESS: boolean;
  97839. MULTIVIEW: boolean;
  97840. /**
  97841. * If the reflection texture on this material is in linear color space
  97842. * @hidden
  97843. */
  97844. IS_REFLECTION_LINEAR: boolean;
  97845. /**
  97846. * If the refraction texture on this material is in linear color space
  97847. * @hidden
  97848. */
  97849. IS_REFRACTION_LINEAR: boolean;
  97850. EXPOSURE: boolean;
  97851. constructor();
  97852. setReflectionMode(modeToEnable: string): void;
  97853. }
  97854. /**
  97855. * This is the default material used in Babylon. It is the best trade off between quality
  97856. * and performances.
  97857. * @see http://doc.babylonjs.com/babylon101/materials
  97858. */
  97859. export class StandardMaterial extends PushMaterial {
  97860. private _diffuseTexture;
  97861. /**
  97862. * The basic texture of the material as viewed under a light.
  97863. */
  97864. diffuseTexture: Nullable<BaseTexture>;
  97865. private _ambientTexture;
  97866. /**
  97867. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  97868. */
  97869. ambientTexture: Nullable<BaseTexture>;
  97870. private _opacityTexture;
  97871. /**
  97872. * Define the transparency of the material from a texture.
  97873. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  97874. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  97875. */
  97876. opacityTexture: Nullable<BaseTexture>;
  97877. private _reflectionTexture;
  97878. /**
  97879. * Define the texture used to display the reflection.
  97880. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97881. */
  97882. reflectionTexture: Nullable<BaseTexture>;
  97883. private _emissiveTexture;
  97884. /**
  97885. * Define texture of the material as if self lit.
  97886. * This will be mixed in the final result even in the absence of light.
  97887. */
  97888. emissiveTexture: Nullable<BaseTexture>;
  97889. private _specularTexture;
  97890. /**
  97891. * Define how the color and intensity of the highlight given by the light in the material.
  97892. */
  97893. specularTexture: Nullable<BaseTexture>;
  97894. private _bumpTexture;
  97895. /**
  97896. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  97897. * 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.
  97898. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  97899. */
  97900. bumpTexture: Nullable<BaseTexture>;
  97901. private _lightmapTexture;
  97902. /**
  97903. * Complex lighting can be computationally expensive to compute at runtime.
  97904. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  97905. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  97906. */
  97907. lightmapTexture: Nullable<BaseTexture>;
  97908. private _refractionTexture;
  97909. /**
  97910. * Define the texture used to display the refraction.
  97911. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  97912. */
  97913. refractionTexture: Nullable<BaseTexture>;
  97914. /**
  97915. * The color of the material lit by the environmental background lighting.
  97916. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  97917. */
  97918. ambientColor: Color3;
  97919. /**
  97920. * The basic color of the material as viewed under a light.
  97921. */
  97922. diffuseColor: Color3;
  97923. /**
  97924. * Define how the color and intensity of the highlight given by the light in the material.
  97925. */
  97926. specularColor: Color3;
  97927. /**
  97928. * Define the color of the material as if self lit.
  97929. * This will be mixed in the final result even in the absence of light.
  97930. */
  97931. emissiveColor: Color3;
  97932. /**
  97933. * Defines how sharp are the highlights in the material.
  97934. * The bigger the value the sharper giving a more glossy feeling to the result.
  97935. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  97936. */
  97937. specularPower: number;
  97938. private _useAlphaFromDiffuseTexture;
  97939. /**
  97940. * Does the transparency come from the diffuse texture alpha channel.
  97941. */
  97942. useAlphaFromDiffuseTexture: boolean;
  97943. private _useEmissiveAsIllumination;
  97944. /**
  97945. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  97946. */
  97947. useEmissiveAsIllumination: boolean;
  97948. private _linkEmissiveWithDiffuse;
  97949. /**
  97950. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  97951. * the emissive level when the final color is close to one.
  97952. */
  97953. linkEmissiveWithDiffuse: boolean;
  97954. private _useSpecularOverAlpha;
  97955. /**
  97956. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  97957. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  97958. */
  97959. useSpecularOverAlpha: boolean;
  97960. private _useReflectionOverAlpha;
  97961. /**
  97962. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  97963. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  97964. */
  97965. useReflectionOverAlpha: boolean;
  97966. private _disableLighting;
  97967. /**
  97968. * Does lights from the scene impacts this material.
  97969. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  97970. */
  97971. disableLighting: boolean;
  97972. private _useObjectSpaceNormalMap;
  97973. /**
  97974. * Allows using an object space normal map (instead of tangent space).
  97975. */
  97976. useObjectSpaceNormalMap: boolean;
  97977. private _useParallax;
  97978. /**
  97979. * Is parallax enabled or not.
  97980. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97981. */
  97982. useParallax: boolean;
  97983. private _useParallaxOcclusion;
  97984. /**
  97985. * Is parallax occlusion enabled or not.
  97986. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  97987. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  97988. */
  97989. useParallaxOcclusion: boolean;
  97990. /**
  97991. * 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.
  97992. */
  97993. parallaxScaleBias: number;
  97994. private _roughness;
  97995. /**
  97996. * Helps to define how blurry the reflections should appears in the material.
  97997. */
  97998. roughness: number;
  97999. /**
  98000. * In case of refraction, define the value of the indice of refraction.
  98001. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98002. */
  98003. indexOfRefraction: number;
  98004. /**
  98005. * Invert the refraction texture alongside the y axis.
  98006. * It can be useful with procedural textures or probe for instance.
  98007. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98008. */
  98009. invertRefractionY: boolean;
  98010. /**
  98011. * Defines the alpha limits in alpha test mode.
  98012. */
  98013. alphaCutOff: number;
  98014. private _useLightmapAsShadowmap;
  98015. /**
  98016. * In case of light mapping, define whether the map contains light or shadow informations.
  98017. */
  98018. useLightmapAsShadowmap: boolean;
  98019. private _diffuseFresnelParameters;
  98020. /**
  98021. * Define the diffuse fresnel parameters of the material.
  98022. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98023. */
  98024. diffuseFresnelParameters: FresnelParameters;
  98025. private _opacityFresnelParameters;
  98026. /**
  98027. * Define the opacity fresnel parameters of the material.
  98028. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98029. */
  98030. opacityFresnelParameters: FresnelParameters;
  98031. private _reflectionFresnelParameters;
  98032. /**
  98033. * Define the reflection fresnel parameters of the material.
  98034. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98035. */
  98036. reflectionFresnelParameters: FresnelParameters;
  98037. private _refractionFresnelParameters;
  98038. /**
  98039. * Define the refraction fresnel parameters of the material.
  98040. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98041. */
  98042. refractionFresnelParameters: FresnelParameters;
  98043. private _emissiveFresnelParameters;
  98044. /**
  98045. * Define the emissive fresnel parameters of the material.
  98046. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98047. */
  98048. emissiveFresnelParameters: FresnelParameters;
  98049. private _useReflectionFresnelFromSpecular;
  98050. /**
  98051. * If true automatically deducts the fresnels values from the material specularity.
  98052. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98053. */
  98054. useReflectionFresnelFromSpecular: boolean;
  98055. private _useGlossinessFromSpecularMapAlpha;
  98056. /**
  98057. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98058. */
  98059. useGlossinessFromSpecularMapAlpha: boolean;
  98060. private _maxSimultaneousLights;
  98061. /**
  98062. * Defines the maximum number of lights that can be used in the material
  98063. */
  98064. maxSimultaneousLights: number;
  98065. private _invertNormalMapX;
  98066. /**
  98067. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98068. */
  98069. invertNormalMapX: boolean;
  98070. private _invertNormalMapY;
  98071. /**
  98072. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98073. */
  98074. invertNormalMapY: boolean;
  98075. private _twoSidedLighting;
  98076. /**
  98077. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98078. */
  98079. twoSidedLighting: boolean;
  98080. /**
  98081. * Default configuration related to image processing available in the standard Material.
  98082. */
  98083. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98084. /**
  98085. * Gets the image processing configuration used either in this material.
  98086. */
  98087. /**
  98088. * Sets the Default image processing configuration used either in the this material.
  98089. *
  98090. * If sets to null, the scene one is in use.
  98091. */
  98092. imageProcessingConfiguration: ImageProcessingConfiguration;
  98093. /**
  98094. * Keep track of the image processing observer to allow dispose and replace.
  98095. */
  98096. private _imageProcessingObserver;
  98097. /**
  98098. * Attaches a new image processing configuration to the Standard Material.
  98099. * @param configuration
  98100. */
  98101. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98102. /**
  98103. * Gets wether the color curves effect is enabled.
  98104. */
  98105. /**
  98106. * Sets wether the color curves effect is enabled.
  98107. */
  98108. cameraColorCurvesEnabled: boolean;
  98109. /**
  98110. * Gets wether the color grading effect is enabled.
  98111. */
  98112. /**
  98113. * Gets wether the color grading effect is enabled.
  98114. */
  98115. cameraColorGradingEnabled: boolean;
  98116. /**
  98117. * Gets wether tonemapping is enabled or not.
  98118. */
  98119. /**
  98120. * Sets wether tonemapping is enabled or not
  98121. */
  98122. cameraToneMappingEnabled: boolean;
  98123. /**
  98124. * The camera exposure used on this material.
  98125. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98126. * This corresponds to a photographic exposure.
  98127. */
  98128. /**
  98129. * The camera exposure used on this material.
  98130. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98131. * This corresponds to a photographic exposure.
  98132. */
  98133. cameraExposure: number;
  98134. /**
  98135. * Gets The camera contrast used on this material.
  98136. */
  98137. /**
  98138. * Sets The camera contrast used on this material.
  98139. */
  98140. cameraContrast: number;
  98141. /**
  98142. * Gets the Color Grading 2D Lookup Texture.
  98143. */
  98144. /**
  98145. * Sets the Color Grading 2D Lookup Texture.
  98146. */
  98147. cameraColorGradingTexture: Nullable<BaseTexture>;
  98148. /**
  98149. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98150. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98151. * 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;
  98152. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98153. */
  98154. /**
  98155. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98156. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98157. * 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;
  98158. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98159. */
  98160. cameraColorCurves: Nullable<ColorCurves>;
  98161. /**
  98162. * Custom callback helping to override the default shader used in the material.
  98163. */
  98164. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98165. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98166. protected _worldViewProjectionMatrix: Matrix;
  98167. protected _globalAmbientColor: Color3;
  98168. protected _useLogarithmicDepth: boolean;
  98169. /**
  98170. * Instantiates a new standard material.
  98171. * This is the default material used in Babylon. It is the best trade off between quality
  98172. * and performances.
  98173. * @see http://doc.babylonjs.com/babylon101/materials
  98174. * @param name Define the name of the material in the scene
  98175. * @param scene Define the scene the material belong to
  98176. */
  98177. constructor(name: string, scene: Scene);
  98178. /**
  98179. * Gets a boolean indicating that current material needs to register RTT
  98180. */
  98181. readonly hasRenderTargetTextures: boolean;
  98182. /**
  98183. * Gets the current class name of the material e.g. "StandardMaterial"
  98184. * Mainly use in serialization.
  98185. * @returns the class name
  98186. */
  98187. getClassName(): string;
  98188. /**
  98189. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98190. * You can try switching to logarithmic depth.
  98191. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98192. */
  98193. useLogarithmicDepth: boolean;
  98194. /**
  98195. * Specifies if the material will require alpha blending
  98196. * @returns a boolean specifying if alpha blending is needed
  98197. */
  98198. needAlphaBlending(): boolean;
  98199. /**
  98200. * Specifies if this material should be rendered in alpha test mode
  98201. * @returns a boolean specifying if an alpha test is needed.
  98202. */
  98203. needAlphaTesting(): boolean;
  98204. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98205. /**
  98206. * Get the texture used for alpha test purpose.
  98207. * @returns the diffuse texture in case of the standard material.
  98208. */
  98209. getAlphaTestTexture(): Nullable<BaseTexture>;
  98210. /**
  98211. * Get if the submesh is ready to be used and all its information available.
  98212. * Child classes can use it to update shaders
  98213. * @param mesh defines the mesh to check
  98214. * @param subMesh defines which submesh to check
  98215. * @param useInstances specifies that instances should be used
  98216. * @returns a boolean indicating that the submesh is ready or not
  98217. */
  98218. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98219. /**
  98220. * Builds the material UBO layouts.
  98221. * Used internally during the effect preparation.
  98222. */
  98223. buildUniformLayout(): void;
  98224. /**
  98225. * Unbinds the material from the mesh
  98226. */
  98227. unbind(): void;
  98228. /**
  98229. * Binds the submesh to this material by preparing the effect and shader to draw
  98230. * @param world defines the world transformation matrix
  98231. * @param mesh defines the mesh containing the submesh
  98232. * @param subMesh defines the submesh to bind the material to
  98233. */
  98234. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98235. /**
  98236. * Get the list of animatables in the material.
  98237. * @returns the list of animatables object used in the material
  98238. */
  98239. getAnimatables(): IAnimatable[];
  98240. /**
  98241. * Gets the active textures from the material
  98242. * @returns an array of textures
  98243. */
  98244. getActiveTextures(): BaseTexture[];
  98245. /**
  98246. * Specifies if the material uses a texture
  98247. * @param texture defines the texture to check against the material
  98248. * @returns a boolean specifying if the material uses the texture
  98249. */
  98250. hasTexture(texture: BaseTexture): boolean;
  98251. /**
  98252. * Disposes the material
  98253. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98254. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98255. */
  98256. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98257. /**
  98258. * Makes a duplicate of the material, and gives it a new name
  98259. * @param name defines the new name for the duplicated material
  98260. * @returns the cloned material
  98261. */
  98262. clone(name: string): StandardMaterial;
  98263. /**
  98264. * Serializes this material in a JSON representation
  98265. * @returns the serialized material object
  98266. */
  98267. serialize(): any;
  98268. /**
  98269. * Creates a standard material from parsed material data
  98270. * @param source defines the JSON representation of the material
  98271. * @param scene defines the hosting scene
  98272. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98273. * @returns a new standard material
  98274. */
  98275. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98276. /**
  98277. * Are diffuse textures enabled in the application.
  98278. */
  98279. static DiffuseTextureEnabled: boolean;
  98280. /**
  98281. * Are ambient textures enabled in the application.
  98282. */
  98283. static AmbientTextureEnabled: boolean;
  98284. /**
  98285. * Are opacity textures enabled in the application.
  98286. */
  98287. static OpacityTextureEnabled: boolean;
  98288. /**
  98289. * Are reflection textures enabled in the application.
  98290. */
  98291. static ReflectionTextureEnabled: boolean;
  98292. /**
  98293. * Are emissive textures enabled in the application.
  98294. */
  98295. static EmissiveTextureEnabled: boolean;
  98296. /**
  98297. * Are specular textures enabled in the application.
  98298. */
  98299. static SpecularTextureEnabled: boolean;
  98300. /**
  98301. * Are bump textures enabled in the application.
  98302. */
  98303. static BumpTextureEnabled: boolean;
  98304. /**
  98305. * Are lightmap textures enabled in the application.
  98306. */
  98307. static LightmapTextureEnabled: boolean;
  98308. /**
  98309. * Are refraction textures enabled in the application.
  98310. */
  98311. static RefractionTextureEnabled: boolean;
  98312. /**
  98313. * Are color grading textures enabled in the application.
  98314. */
  98315. static ColorGradingTextureEnabled: boolean;
  98316. /**
  98317. * Are fresnels enabled in the application.
  98318. */
  98319. static FresnelEnabled: boolean;
  98320. }
  98321. }
  98322. declare module BABYLON {
  98323. /**
  98324. * A class extending Texture allowing drawing on a texture
  98325. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98326. */
  98327. export class DynamicTexture extends Texture {
  98328. private _generateMipMaps;
  98329. private _canvas;
  98330. private _context;
  98331. private _engine;
  98332. /**
  98333. * Creates a DynamicTexture
  98334. * @param name defines the name of the texture
  98335. * @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
  98336. * @param scene defines the scene where you want the texture
  98337. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98338. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98339. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98340. */
  98341. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98342. /**
  98343. * Get the current class name of the texture useful for serialization or dynamic coding.
  98344. * @returns "DynamicTexture"
  98345. */
  98346. getClassName(): string;
  98347. /**
  98348. * Gets the current state of canRescale
  98349. */
  98350. readonly canRescale: boolean;
  98351. private _recreate;
  98352. /**
  98353. * Scales the texture
  98354. * @param ratio the scale factor to apply to both width and height
  98355. */
  98356. scale(ratio: number): void;
  98357. /**
  98358. * Resizes the texture
  98359. * @param width the new width
  98360. * @param height the new height
  98361. */
  98362. scaleTo(width: number, height: number): void;
  98363. /**
  98364. * Gets the context of the canvas used by the texture
  98365. * @returns the canvas context of the dynamic texture
  98366. */
  98367. getContext(): CanvasRenderingContext2D;
  98368. /**
  98369. * Clears the texture
  98370. */
  98371. clear(): void;
  98372. /**
  98373. * Updates the texture
  98374. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98375. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98376. */
  98377. update(invertY?: boolean, premulAlpha?: boolean): void;
  98378. /**
  98379. * Draws text onto the texture
  98380. * @param text defines the text to be drawn
  98381. * @param x defines the placement of the text from the left
  98382. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98383. * @param font defines the font to be used with font-style, font-size, font-name
  98384. * @param color defines the color used for the text
  98385. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98386. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98387. * @param update defines whether texture is immediately update (default is true)
  98388. */
  98389. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98390. /**
  98391. * Clones the texture
  98392. * @returns the clone of the texture.
  98393. */
  98394. clone(): DynamicTexture;
  98395. /**
  98396. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98397. * @returns a serialized dynamic texture object
  98398. */
  98399. serialize(): any;
  98400. /** @hidden */
  98401. _rebuild(): void;
  98402. }
  98403. }
  98404. declare module BABYLON {
  98405. /** @hidden */
  98406. export var imageProcessingPixelShader: {
  98407. name: string;
  98408. shader: string;
  98409. };
  98410. }
  98411. declare module BABYLON {
  98412. /**
  98413. * ImageProcessingPostProcess
  98414. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98415. */
  98416. export class ImageProcessingPostProcess extends PostProcess {
  98417. /**
  98418. * Default configuration related to image processing available in the PBR Material.
  98419. */
  98420. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98421. /**
  98422. * Gets the image processing configuration used either in this material.
  98423. */
  98424. /**
  98425. * Sets the Default image processing configuration used either in the this material.
  98426. *
  98427. * If sets to null, the scene one is in use.
  98428. */
  98429. imageProcessingConfiguration: ImageProcessingConfiguration;
  98430. /**
  98431. * Keep track of the image processing observer to allow dispose and replace.
  98432. */
  98433. private _imageProcessingObserver;
  98434. /**
  98435. * Attaches a new image processing configuration to the PBR Material.
  98436. * @param configuration
  98437. */
  98438. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98439. /**
  98440. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98441. */
  98442. /**
  98443. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98444. */
  98445. colorCurves: Nullable<ColorCurves>;
  98446. /**
  98447. * Gets wether the color curves effect is enabled.
  98448. */
  98449. /**
  98450. * Sets wether the color curves effect is enabled.
  98451. */
  98452. colorCurvesEnabled: boolean;
  98453. /**
  98454. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98455. */
  98456. /**
  98457. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98458. */
  98459. colorGradingTexture: Nullable<BaseTexture>;
  98460. /**
  98461. * Gets wether the color grading effect is enabled.
  98462. */
  98463. /**
  98464. * Gets wether the color grading effect is enabled.
  98465. */
  98466. colorGradingEnabled: boolean;
  98467. /**
  98468. * Gets exposure used in the effect.
  98469. */
  98470. /**
  98471. * Sets exposure used in the effect.
  98472. */
  98473. exposure: number;
  98474. /**
  98475. * Gets wether tonemapping is enabled or not.
  98476. */
  98477. /**
  98478. * Sets wether tonemapping is enabled or not
  98479. */
  98480. toneMappingEnabled: boolean;
  98481. /**
  98482. * Gets the type of tone mapping effect.
  98483. */
  98484. /**
  98485. * Sets the type of tone mapping effect.
  98486. */
  98487. toneMappingType: number;
  98488. /**
  98489. * Gets contrast used in the effect.
  98490. */
  98491. /**
  98492. * Sets contrast used in the effect.
  98493. */
  98494. contrast: number;
  98495. /**
  98496. * Gets Vignette stretch size.
  98497. */
  98498. /**
  98499. * Sets Vignette stretch size.
  98500. */
  98501. vignetteStretch: number;
  98502. /**
  98503. * Gets Vignette centre X Offset.
  98504. */
  98505. /**
  98506. * Sets Vignette centre X Offset.
  98507. */
  98508. vignetteCentreX: number;
  98509. /**
  98510. * Gets Vignette centre Y Offset.
  98511. */
  98512. /**
  98513. * Sets Vignette centre Y Offset.
  98514. */
  98515. vignetteCentreY: number;
  98516. /**
  98517. * Gets Vignette weight or intensity of the vignette effect.
  98518. */
  98519. /**
  98520. * Sets Vignette weight or intensity of the vignette effect.
  98521. */
  98522. vignetteWeight: number;
  98523. /**
  98524. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98525. * if vignetteEnabled is set to true.
  98526. */
  98527. /**
  98528. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98529. * if vignetteEnabled is set to true.
  98530. */
  98531. vignetteColor: Color4;
  98532. /**
  98533. * Gets Camera field of view used by the Vignette effect.
  98534. */
  98535. /**
  98536. * Sets Camera field of view used by the Vignette effect.
  98537. */
  98538. vignetteCameraFov: number;
  98539. /**
  98540. * Gets the vignette blend mode allowing different kind of effect.
  98541. */
  98542. /**
  98543. * Sets the vignette blend mode allowing different kind of effect.
  98544. */
  98545. vignetteBlendMode: number;
  98546. /**
  98547. * Gets wether the vignette effect is enabled.
  98548. */
  98549. /**
  98550. * Sets wether the vignette effect is enabled.
  98551. */
  98552. vignetteEnabled: boolean;
  98553. private _fromLinearSpace;
  98554. /**
  98555. * Gets wether the input of the processing is in Gamma or Linear Space.
  98556. */
  98557. /**
  98558. * Sets wether the input of the processing is in Gamma or Linear Space.
  98559. */
  98560. fromLinearSpace: boolean;
  98561. /**
  98562. * Defines cache preventing GC.
  98563. */
  98564. private _defines;
  98565. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98566. /**
  98567. * "ImageProcessingPostProcess"
  98568. * @returns "ImageProcessingPostProcess"
  98569. */
  98570. getClassName(): string;
  98571. protected _updateParameters(): void;
  98572. dispose(camera?: Camera): void;
  98573. }
  98574. }
  98575. declare module BABYLON {
  98576. /**
  98577. * Class containing static functions to help procedurally build meshes
  98578. */
  98579. export class GroundBuilder {
  98580. /**
  98581. * Creates a ground mesh
  98582. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98583. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98585. * @param name defines the name of the mesh
  98586. * @param options defines the options used to create the mesh
  98587. * @param scene defines the hosting scene
  98588. * @returns the ground mesh
  98589. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98590. */
  98591. static CreateGround(name: string, options: {
  98592. width?: number;
  98593. height?: number;
  98594. subdivisions?: number;
  98595. subdivisionsX?: number;
  98596. subdivisionsY?: number;
  98597. updatable?: boolean;
  98598. }, scene: any): Mesh;
  98599. /**
  98600. * Creates a tiled ground mesh
  98601. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98602. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98603. * * 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
  98604. * * 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
  98605. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98606. * @param name defines the name of the mesh
  98607. * @param options defines the options used to create the mesh
  98608. * @param scene defines the hosting scene
  98609. * @returns the tiled ground mesh
  98610. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98611. */
  98612. static CreateTiledGround(name: string, options: {
  98613. xmin: number;
  98614. zmin: number;
  98615. xmax: number;
  98616. zmax: number;
  98617. subdivisions?: {
  98618. w: number;
  98619. h: number;
  98620. };
  98621. precision?: {
  98622. w: number;
  98623. h: number;
  98624. };
  98625. updatable?: boolean;
  98626. }, scene?: Nullable<Scene>): Mesh;
  98627. /**
  98628. * Creates a ground mesh from a height map
  98629. * * The parameter `url` sets the URL of the height map image resource.
  98630. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98631. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98632. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98633. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98634. * * 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.
  98635. * * 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).
  98636. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98637. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98638. * @param name defines the name of the mesh
  98639. * @param url defines the url to the height map
  98640. * @param options defines the options used to create the mesh
  98641. * @param scene defines the hosting scene
  98642. * @returns the ground mesh
  98643. * @see https://doc.babylonjs.com/babylon101/height_map
  98644. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98645. */
  98646. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98647. width?: number;
  98648. height?: number;
  98649. subdivisions?: number;
  98650. minHeight?: number;
  98651. maxHeight?: number;
  98652. colorFilter?: Color3;
  98653. alphaFilter?: number;
  98654. updatable?: boolean;
  98655. onReady?: (mesh: GroundMesh) => void;
  98656. }, scene?: Nullable<Scene>): GroundMesh;
  98657. }
  98658. }
  98659. declare module BABYLON {
  98660. /**
  98661. * Class containing static functions to help procedurally build meshes
  98662. */
  98663. export class TorusBuilder {
  98664. /**
  98665. * Creates a torus mesh
  98666. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98667. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98668. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98669. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98670. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98671. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98672. * @param name defines the name of the mesh
  98673. * @param options defines the options used to create the mesh
  98674. * @param scene defines the hosting scene
  98675. * @returns the torus mesh
  98676. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98677. */
  98678. static CreateTorus(name: string, options: {
  98679. diameter?: number;
  98680. thickness?: number;
  98681. tessellation?: number;
  98682. updatable?: boolean;
  98683. sideOrientation?: number;
  98684. frontUVs?: Vector4;
  98685. backUVs?: Vector4;
  98686. }, scene: any): Mesh;
  98687. }
  98688. }
  98689. declare module BABYLON {
  98690. /**
  98691. * Class containing static functions to help procedurally build meshes
  98692. */
  98693. export class CylinderBuilder {
  98694. /**
  98695. * Creates a cylinder or a cone mesh
  98696. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98697. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98698. * * 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.
  98699. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98700. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98701. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98702. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98703. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98704. * * 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).
  98705. * * 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
  98706. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98707. * * 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
  98708. * * 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.
  98709. * * If `enclose` is false, a ring surface is one element.
  98710. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98711. * * 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
  98712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98715. * @param name defines the name of the mesh
  98716. * @param options defines the options used to create the mesh
  98717. * @param scene defines the hosting scene
  98718. * @returns the cylinder mesh
  98719. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98720. */
  98721. static CreateCylinder(name: string, options: {
  98722. height?: number;
  98723. diameterTop?: number;
  98724. diameterBottom?: number;
  98725. diameter?: number;
  98726. tessellation?: number;
  98727. subdivisions?: number;
  98728. arc?: number;
  98729. faceColors?: Color4[];
  98730. faceUV?: Vector4[];
  98731. updatable?: boolean;
  98732. hasRings?: boolean;
  98733. enclose?: boolean;
  98734. sideOrientation?: number;
  98735. frontUVs?: Vector4;
  98736. backUVs?: Vector4;
  98737. }, scene: any): Mesh;
  98738. }
  98739. }
  98740. declare module BABYLON {
  98741. /**
  98742. * Manager for handling gamepads
  98743. */
  98744. export class GamepadManager {
  98745. private _scene?;
  98746. private _babylonGamepads;
  98747. private _oneGamepadConnected;
  98748. /** @hidden */
  98749. _isMonitoring: boolean;
  98750. private _gamepadEventSupported;
  98751. private _gamepadSupport;
  98752. /**
  98753. * observable to be triggered when the gamepad controller has been connected
  98754. */
  98755. onGamepadConnectedObservable: Observable<Gamepad>;
  98756. /**
  98757. * observable to be triggered when the gamepad controller has been disconnected
  98758. */
  98759. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98760. private _onGamepadConnectedEvent;
  98761. private _onGamepadDisconnectedEvent;
  98762. /**
  98763. * Initializes the gamepad manager
  98764. * @param _scene BabylonJS scene
  98765. */
  98766. constructor(_scene?: Scene | undefined);
  98767. /**
  98768. * The gamepads in the game pad manager
  98769. */
  98770. readonly gamepads: Gamepad[];
  98771. /**
  98772. * Get the gamepad controllers based on type
  98773. * @param type The type of gamepad controller
  98774. * @returns Nullable gamepad
  98775. */
  98776. getGamepadByType(type?: number): Nullable<Gamepad>;
  98777. /**
  98778. * Disposes the gamepad manager
  98779. */
  98780. dispose(): void;
  98781. private _addNewGamepad;
  98782. private _startMonitoringGamepads;
  98783. private _stopMonitoringGamepads;
  98784. /** @hidden */
  98785. _checkGamepadsStatus(): void;
  98786. private _updateGamepadObjects;
  98787. }
  98788. }
  98789. declare module BABYLON {
  98790. interface Scene {
  98791. /** @hidden */
  98792. _gamepadManager: Nullable<GamepadManager>;
  98793. /**
  98794. * Gets the gamepad manager associated with the scene
  98795. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98796. */
  98797. gamepadManager: GamepadManager;
  98798. }
  98799. /**
  98800. * Interface representing a free camera inputs manager
  98801. */
  98802. interface FreeCameraInputsManager {
  98803. /**
  98804. * Adds gamepad input support to the FreeCameraInputsManager.
  98805. * @returns the FreeCameraInputsManager
  98806. */
  98807. addGamepad(): FreeCameraInputsManager;
  98808. }
  98809. /**
  98810. * Interface representing an arc rotate camera inputs manager
  98811. */
  98812. interface ArcRotateCameraInputsManager {
  98813. /**
  98814. * Adds gamepad input support to the ArcRotateCamera InputManager.
  98815. * @returns the camera inputs manager
  98816. */
  98817. addGamepad(): ArcRotateCameraInputsManager;
  98818. }
  98819. /**
  98820. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  98821. */
  98822. export class GamepadSystemSceneComponent implements ISceneComponent {
  98823. /**
  98824. * The component name helpfull to identify the component in the list of scene components.
  98825. */
  98826. readonly name: string;
  98827. /**
  98828. * The scene the component belongs to.
  98829. */
  98830. scene: Scene;
  98831. /**
  98832. * Creates a new instance of the component for the given scene
  98833. * @param scene Defines the scene to register the component in
  98834. */
  98835. constructor(scene: Scene);
  98836. /**
  98837. * Registers the component in a given scene
  98838. */
  98839. register(): void;
  98840. /**
  98841. * Rebuilds the elements related to this component in case of
  98842. * context lost for instance.
  98843. */
  98844. rebuild(): void;
  98845. /**
  98846. * Disposes the component and the associated ressources
  98847. */
  98848. dispose(): void;
  98849. private _beforeCameraUpdate;
  98850. }
  98851. }
  98852. declare module BABYLON {
  98853. /**
  98854. * Options to modify the vr teleportation behavior.
  98855. */
  98856. export interface VRTeleportationOptions {
  98857. /**
  98858. * The name of the mesh which should be used as the teleportation floor. (default: null)
  98859. */
  98860. floorMeshName?: string;
  98861. /**
  98862. * A list of meshes to be used as the teleportation floor. (default: empty)
  98863. */
  98864. floorMeshes?: Mesh[];
  98865. }
  98866. /**
  98867. * Options to modify the vr experience helper's behavior.
  98868. */
  98869. export interface VRExperienceHelperOptions extends WebVROptions {
  98870. /**
  98871. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  98872. */
  98873. createDeviceOrientationCamera?: boolean;
  98874. /**
  98875. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  98876. */
  98877. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  98878. /**
  98879. * Uses the main button on the controller to toggle the laser casted. (default: true)
  98880. */
  98881. laserToggle?: boolean;
  98882. /**
  98883. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  98884. */
  98885. floorMeshes?: Mesh[];
  98886. /**
  98887. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  98888. */
  98889. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  98890. }
  98891. /**
  98892. * Event containing information after VR has been entered
  98893. */
  98894. export class OnAfterEnteringVRObservableEvent {
  98895. /**
  98896. * If entering vr was successful
  98897. */
  98898. success: boolean;
  98899. }
  98900. /**
  98901. * Helps to quickly add VR support to an existing scene.
  98902. * See http://doc.babylonjs.com/how_to/webvr_helper
  98903. */
  98904. export class VRExperienceHelper {
  98905. /** Options to modify the vr experience helper's behavior. */
  98906. webVROptions: VRExperienceHelperOptions;
  98907. private _scene;
  98908. private _position;
  98909. private _btnVR;
  98910. private _btnVRDisplayed;
  98911. private _webVRsupported;
  98912. private _webVRready;
  98913. private _webVRrequesting;
  98914. private _webVRpresenting;
  98915. private _hasEnteredVR;
  98916. private _fullscreenVRpresenting;
  98917. private _canvas;
  98918. private _webVRCamera;
  98919. private _vrDeviceOrientationCamera;
  98920. private _deviceOrientationCamera;
  98921. private _existingCamera;
  98922. private _onKeyDown;
  98923. private _onVrDisplayPresentChange;
  98924. private _onVRDisplayChanged;
  98925. private _onVRRequestPresentStart;
  98926. private _onVRRequestPresentComplete;
  98927. /**
  98928. * Observable raised right before entering VR.
  98929. */
  98930. onEnteringVRObservable: Observable<VRExperienceHelper>;
  98931. /**
  98932. * Observable raised when entering VR has completed.
  98933. */
  98934. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  98935. /**
  98936. * Observable raised when exiting VR.
  98937. */
  98938. onExitingVRObservable: Observable<VRExperienceHelper>;
  98939. /**
  98940. * Observable raised when controller mesh is loaded.
  98941. */
  98942. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98943. /** Return this.onEnteringVRObservable
  98944. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  98945. */
  98946. readonly onEnteringVR: Observable<VRExperienceHelper>;
  98947. /** Return this.onExitingVRObservable
  98948. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  98949. */
  98950. readonly onExitingVR: Observable<VRExperienceHelper>;
  98951. /** Return this.onControllerMeshLoadedObservable
  98952. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  98953. */
  98954. readonly onControllerMeshLoaded: Observable<WebVRController>;
  98955. private _rayLength;
  98956. private _useCustomVRButton;
  98957. private _teleportationRequested;
  98958. private _teleportActive;
  98959. private _floorMeshName;
  98960. private _floorMeshesCollection;
  98961. private _rotationAllowed;
  98962. private _teleportBackwardsVector;
  98963. private _teleportationTarget;
  98964. private _isDefaultTeleportationTarget;
  98965. private _postProcessMove;
  98966. private _teleportationFillColor;
  98967. private _teleportationBorderColor;
  98968. private _rotationAngle;
  98969. private _haloCenter;
  98970. private _cameraGazer;
  98971. private _padSensibilityUp;
  98972. private _padSensibilityDown;
  98973. private _leftController;
  98974. private _rightController;
  98975. /**
  98976. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  98977. */
  98978. onNewMeshSelected: Observable<AbstractMesh>;
  98979. /**
  98980. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  98981. */
  98982. onNewMeshPicked: Observable<PickingInfo>;
  98983. private _circleEase;
  98984. /**
  98985. * Observable raised before camera teleportation
  98986. */
  98987. onBeforeCameraTeleport: Observable<Vector3>;
  98988. /**
  98989. * Observable raised after camera teleportation
  98990. */
  98991. onAfterCameraTeleport: Observable<Vector3>;
  98992. /**
  98993. * Observable raised when current selected mesh gets unselected
  98994. */
  98995. onSelectedMeshUnselected: Observable<AbstractMesh>;
  98996. private _raySelectionPredicate;
  98997. /**
  98998. * To be optionaly changed by user to define custom ray selection
  98999. */
  99000. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99001. /**
  99002. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99003. */
  99004. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99005. /**
  99006. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99007. */
  99008. teleportationEnabled: boolean;
  99009. private _defaultHeight;
  99010. private _teleportationInitialized;
  99011. private _interactionsEnabled;
  99012. private _interactionsRequested;
  99013. private _displayGaze;
  99014. private _displayLaserPointer;
  99015. /**
  99016. * The mesh used to display where the user is going to teleport.
  99017. */
  99018. /**
  99019. * Sets the mesh to be used to display where the user is going to teleport.
  99020. */
  99021. teleportationTarget: Mesh;
  99022. /**
  99023. * 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
  99024. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99025. * See http://doc.babylonjs.com/resources/baking_transformations
  99026. */
  99027. gazeTrackerMesh: Mesh;
  99028. /**
  99029. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99030. */
  99031. updateGazeTrackerScale: boolean;
  99032. /**
  99033. * If the gaze trackers color should be updated when selecting meshes
  99034. */
  99035. updateGazeTrackerColor: boolean;
  99036. /**
  99037. * The gaze tracking mesh corresponding to the left controller
  99038. */
  99039. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99040. /**
  99041. * The gaze tracking mesh corresponding to the right controller
  99042. */
  99043. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99044. /**
  99045. * If the ray of the gaze should be displayed.
  99046. */
  99047. /**
  99048. * Sets if the ray of the gaze should be displayed.
  99049. */
  99050. displayGaze: boolean;
  99051. /**
  99052. * If the ray of the LaserPointer should be displayed.
  99053. */
  99054. /**
  99055. * Sets if the ray of the LaserPointer should be displayed.
  99056. */
  99057. displayLaserPointer: boolean;
  99058. /**
  99059. * The deviceOrientationCamera used as the camera when not in VR.
  99060. */
  99061. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99062. /**
  99063. * Based on the current WebVR support, returns the current VR camera used.
  99064. */
  99065. readonly currentVRCamera: Nullable<Camera>;
  99066. /**
  99067. * The webVRCamera which is used when in VR.
  99068. */
  99069. readonly webVRCamera: WebVRFreeCamera;
  99070. /**
  99071. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99072. */
  99073. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99074. private readonly _teleportationRequestInitiated;
  99075. /**
  99076. * Defines wether or not Pointer lock should be requested when switching to
  99077. * full screen.
  99078. */
  99079. requestPointerLockOnFullScreen: boolean;
  99080. /**
  99081. * Instantiates a VRExperienceHelper.
  99082. * Helps to quickly add VR support to an existing scene.
  99083. * @param scene The scene the VRExperienceHelper belongs to.
  99084. * @param webVROptions Options to modify the vr experience helper's behavior.
  99085. */
  99086. constructor(scene: Scene,
  99087. /** Options to modify the vr experience helper's behavior. */
  99088. webVROptions?: VRExperienceHelperOptions);
  99089. private _onDefaultMeshLoaded;
  99090. private _onResize;
  99091. private _onFullscreenChange;
  99092. /**
  99093. * Gets a value indicating if we are currently in VR mode.
  99094. */
  99095. readonly isInVRMode: boolean;
  99096. private onVrDisplayPresentChange;
  99097. private onVRDisplayChanged;
  99098. private moveButtonToBottomRight;
  99099. private displayVRButton;
  99100. private updateButtonVisibility;
  99101. private _cachedAngularSensibility;
  99102. /**
  99103. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99104. * Otherwise, will use the fullscreen API.
  99105. */
  99106. enterVR(): void;
  99107. /**
  99108. * Attempt to exit VR, or fullscreen.
  99109. */
  99110. exitVR(): void;
  99111. /**
  99112. * The position of the vr experience helper.
  99113. */
  99114. /**
  99115. * Sets the position of the vr experience helper.
  99116. */
  99117. position: Vector3;
  99118. /**
  99119. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99120. */
  99121. enableInteractions(): void;
  99122. private readonly _noControllerIsActive;
  99123. private beforeRender;
  99124. private _isTeleportationFloor;
  99125. /**
  99126. * Adds a floor mesh to be used for teleportation.
  99127. * @param floorMesh the mesh to be used for teleportation.
  99128. */
  99129. addFloorMesh(floorMesh: Mesh): void;
  99130. /**
  99131. * Removes a floor mesh from being used for teleportation.
  99132. * @param floorMesh the mesh to be removed.
  99133. */
  99134. removeFloorMesh(floorMesh: Mesh): void;
  99135. /**
  99136. * Enables interactions and teleportation using the VR controllers and gaze.
  99137. * @param vrTeleportationOptions options to modify teleportation behavior.
  99138. */
  99139. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99140. private _onNewGamepadConnected;
  99141. private _tryEnableInteractionOnController;
  99142. private _onNewGamepadDisconnected;
  99143. private _enableInteractionOnController;
  99144. private _checkTeleportWithRay;
  99145. private _checkRotate;
  99146. private _checkTeleportBackwards;
  99147. private _enableTeleportationOnController;
  99148. private _createTeleportationCircles;
  99149. private _displayTeleportationTarget;
  99150. private _hideTeleportationTarget;
  99151. private _rotateCamera;
  99152. private _moveTeleportationSelectorTo;
  99153. private _workingVector;
  99154. private _workingQuaternion;
  99155. private _workingMatrix;
  99156. /**
  99157. * Teleports the users feet to the desired location
  99158. * @param location The location where the user's feet should be placed
  99159. */
  99160. teleportCamera(location: Vector3): void;
  99161. private _convertNormalToDirectionOfRay;
  99162. private _castRayAndSelectObject;
  99163. private _notifySelectedMeshUnselected;
  99164. /**
  99165. * Sets the color of the laser ray from the vr controllers.
  99166. * @param color new color for the ray.
  99167. */
  99168. changeLaserColor(color: Color3): void;
  99169. /**
  99170. * Sets the color of the ray from the vr headsets gaze.
  99171. * @param color new color for the ray.
  99172. */
  99173. changeGazeColor(color: Color3): void;
  99174. /**
  99175. * Exits VR and disposes of the vr experience helper
  99176. */
  99177. dispose(): void;
  99178. /**
  99179. * Gets the name of the VRExperienceHelper class
  99180. * @returns "VRExperienceHelper"
  99181. */
  99182. getClassName(): string;
  99183. }
  99184. }
  99185. declare module BABYLON {
  99186. /**
  99187. * Manages an XRSession
  99188. * @see https://doc.babylonjs.com/how_to/webxr
  99189. */
  99190. export class WebXRSessionManager implements IDisposable {
  99191. private scene;
  99192. /**
  99193. * Fires every time a new xrFrame arrives which can be used to update the camera
  99194. */
  99195. onXRFrameObservable: Observable<any>;
  99196. /**
  99197. * Fires when the xr session is ended either by the device or manually done
  99198. */
  99199. onXRSessionEnded: Observable<any>;
  99200. /** @hidden */
  99201. _xrSession: XRSession;
  99202. /** @hidden */
  99203. _frameOfReference: XRFrameOfReference;
  99204. /** @hidden */
  99205. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99206. /** @hidden */
  99207. _currentXRFrame: Nullable<XRFrame>;
  99208. private _xrNavigator;
  99209. private _xrDevice;
  99210. private _tmpMatrix;
  99211. /**
  99212. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99213. * @param scene The scene which the session should be created for
  99214. */
  99215. constructor(scene: Scene);
  99216. /**
  99217. * Initializes the manager
  99218. * After initialization enterXR can be called to start an XR session
  99219. * @returns Promise which resolves after it is initialized
  99220. */
  99221. initializeAsync(): Promise<void>;
  99222. /**
  99223. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99224. * @param sessionCreationOptions xr options to create the session with
  99225. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99226. * @returns Promise which resolves after it enters XR
  99227. */
  99228. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99229. /**
  99230. * Stops the xrSession and restores the renderloop
  99231. * @returns Promise which resolves after it exits XR
  99232. */
  99233. exitXRAsync(): Promise<void>;
  99234. /**
  99235. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99236. * @param ray ray to cast into the environment
  99237. * @returns Promise which resolves with a collision point in the environment if it exists
  99238. */
  99239. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99240. /**
  99241. * Checks if a session would be supported for the creation options specified
  99242. * @param options creation options to check if they are supported
  99243. * @returns true if supported
  99244. */
  99245. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99246. /**
  99247. * @hidden
  99248. * Converts the render layer of xrSession to a render target
  99249. * @param session session to create render target for
  99250. * @param scene scene the new render target should be created for
  99251. */
  99252. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99253. /**
  99254. * Disposes of the session manager
  99255. */
  99256. dispose(): void;
  99257. }
  99258. }
  99259. declare module BABYLON {
  99260. /**
  99261. * WebXR Camera which holds the views for the xrSession
  99262. * @see https://doc.babylonjs.com/how_to/webxr
  99263. */
  99264. export class WebXRCamera extends FreeCamera {
  99265. private static _TmpMatrix;
  99266. /**
  99267. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99268. * @param name the name of the camera
  99269. * @param scene the scene to add the camera to
  99270. */
  99271. constructor(name: string, scene: Scene);
  99272. private _updateNumberOfRigCameras;
  99273. /** @hidden */
  99274. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99275. /**
  99276. * Updates the cameras position from the current pose information of the XR session
  99277. * @param xrSessionManager the session containing pose information
  99278. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99279. */
  99280. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99281. }
  99282. }
  99283. declare module BABYLON {
  99284. /**
  99285. * States of the webXR experience
  99286. */
  99287. export enum WebXRState {
  99288. /**
  99289. * Transitioning to being in XR mode
  99290. */
  99291. ENTERING_XR = 0,
  99292. /**
  99293. * Transitioning to non XR mode
  99294. */
  99295. EXITING_XR = 1,
  99296. /**
  99297. * In XR mode and presenting
  99298. */
  99299. IN_XR = 2,
  99300. /**
  99301. * Not entered XR mode
  99302. */
  99303. NOT_IN_XR = 3
  99304. }
  99305. /**
  99306. * Helper class used to enable XR
  99307. * @see https://doc.babylonjs.com/how_to/webxr
  99308. */
  99309. export class WebXRExperienceHelper implements IDisposable {
  99310. private scene;
  99311. /**
  99312. * 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
  99313. */
  99314. container: AbstractMesh;
  99315. /**
  99316. * Camera used to render xr content
  99317. */
  99318. camera: WebXRCamera;
  99319. /**
  99320. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99321. */
  99322. state: WebXRState;
  99323. private _setState;
  99324. private static _TmpVector;
  99325. /**
  99326. * Fires when the state of the experience helper has changed
  99327. */
  99328. onStateChangedObservable: Observable<WebXRState>;
  99329. /** @hidden */
  99330. _sessionManager: WebXRSessionManager;
  99331. private _nonVRCamera;
  99332. private _originalSceneAutoClear;
  99333. private _supported;
  99334. /**
  99335. * Creates the experience helper
  99336. * @param scene the scene to attach the experience helper to
  99337. * @returns a promise for the experience helper
  99338. */
  99339. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99340. /**
  99341. * Creates a WebXRExperienceHelper
  99342. * @param scene The scene the helper should be created in
  99343. */
  99344. private constructor();
  99345. /**
  99346. * Exits XR mode and returns the scene to its original state
  99347. * @returns promise that resolves after xr mode has exited
  99348. */
  99349. exitXRAsync(): Promise<void>;
  99350. /**
  99351. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99352. * @param sessionCreationOptions options for the XR session
  99353. * @param frameOfReference frame of reference of the XR session
  99354. * @returns promise that resolves after xr mode has entered
  99355. */
  99356. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99357. /**
  99358. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99359. * @param ray ray to cast into the environment
  99360. * @returns Promise which resolves with a collision point in the environment if it exists
  99361. */
  99362. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99363. /**
  99364. * Updates the global position of the camera by moving the camera's container
  99365. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99366. * @param position The desired global position of the camera
  99367. */
  99368. setPositionOfCameraUsingContainer(position: Vector3): void;
  99369. /**
  99370. * Rotates the xr camera by rotating the camera's container around the camera's position
  99371. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99372. * @param rotation the desired quaternion rotation to apply to the camera
  99373. */
  99374. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99375. /**
  99376. * Checks if the creation options are supported by the xr session
  99377. * @param options creation options
  99378. * @returns true if supported
  99379. */
  99380. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99381. /**
  99382. * Disposes of the experience helper
  99383. */
  99384. dispose(): void;
  99385. }
  99386. }
  99387. declare module BABYLON {
  99388. /**
  99389. * Button which can be used to enter a different mode of XR
  99390. */
  99391. export class WebXREnterExitUIButton {
  99392. /** button element */
  99393. element: HTMLElement;
  99394. /** XR initialization options for the button */
  99395. initializationOptions: XRSessionCreationOptions;
  99396. /**
  99397. * Creates a WebXREnterExitUIButton
  99398. * @param element button element
  99399. * @param initializationOptions XR initialization options for the button
  99400. */
  99401. constructor(
  99402. /** button element */
  99403. element: HTMLElement,
  99404. /** XR initialization options for the button */
  99405. initializationOptions: XRSessionCreationOptions);
  99406. /**
  99407. * Overwritable function which can be used to update the button's visuals when the state changes
  99408. * @param activeButton the current active button in the UI
  99409. */
  99410. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99411. }
  99412. /**
  99413. * Options to create the webXR UI
  99414. */
  99415. export class WebXREnterExitUIOptions {
  99416. /**
  99417. * Context to enter xr with
  99418. */
  99419. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99420. /**
  99421. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99422. */
  99423. customButtons?: Array<WebXREnterExitUIButton>;
  99424. }
  99425. /**
  99426. * UI to allow the user to enter/exit XR mode
  99427. */
  99428. export class WebXREnterExitUI implements IDisposable {
  99429. private scene;
  99430. private _overlay;
  99431. private _buttons;
  99432. private _activeButton;
  99433. /**
  99434. * Fired every time the active button is changed.
  99435. *
  99436. * When xr is entered via a button that launches xr that button will be the callback parameter
  99437. *
  99438. * When exiting xr the callback parameter will be null)
  99439. */
  99440. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99441. /**
  99442. * Creates UI to allow the user to enter/exit XR mode
  99443. * @param scene the scene to add the ui to
  99444. * @param helper the xr experience helper to enter/exit xr with
  99445. * @param options options to configure the UI
  99446. * @returns the created ui
  99447. */
  99448. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99449. private constructor();
  99450. private _updateButtons;
  99451. /**
  99452. * Disposes of the object
  99453. */
  99454. dispose(): void;
  99455. }
  99456. }
  99457. declare module BABYLON {
  99458. /**
  99459. * Represents an XR input
  99460. */
  99461. export class WebXRController {
  99462. /**
  99463. * 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
  99464. */
  99465. grip?: AbstractMesh;
  99466. /**
  99467. * Pointer which can be used to select objects or attach a visible laser to
  99468. */
  99469. pointer: AbstractMesh;
  99470. /**
  99471. * Creates the controller
  99472. * @see https://doc.babylonjs.com/how_to/webxr
  99473. * @param scene the scene which the controller should be associated to
  99474. */
  99475. constructor(scene: Scene);
  99476. /**
  99477. * Disposes of the object
  99478. */
  99479. dispose(): void;
  99480. }
  99481. /**
  99482. * XR input used to track XR inputs such as controllers/rays
  99483. */
  99484. export class WebXRInput implements IDisposable {
  99485. private helper;
  99486. /**
  99487. * XR controllers being tracked
  99488. */
  99489. controllers: Array<WebXRController>;
  99490. private _tmpMatrix;
  99491. private _frameObserver;
  99492. /**
  99493. * Initializes the WebXRInput
  99494. * @param helper experience helper which the input should be created for
  99495. */
  99496. constructor(helper: WebXRExperienceHelper);
  99497. /**
  99498. * Disposes of the object
  99499. */
  99500. dispose(): void;
  99501. }
  99502. }
  99503. declare module BABYLON {
  99504. /**
  99505. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99506. */
  99507. export class WebXRManagedOutputCanvas implements IDisposable {
  99508. private _canvas;
  99509. /**
  99510. * xrpresent context of the canvas which can be used to display/mirror xr content
  99511. */
  99512. canvasContext: Nullable<WebGLRenderingContext>;
  99513. /**
  99514. * Initializes the canvas to be added/removed upon entering/exiting xr
  99515. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99516. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99517. */
  99518. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99519. /**
  99520. * Disposes of the object
  99521. */
  99522. dispose(): void;
  99523. private _setManagedOutputCanvas;
  99524. private _addCanvas;
  99525. private _removeCanvas;
  99526. }
  99527. }
  99528. declare module BABYLON {
  99529. /**
  99530. * Contains an array of blocks representing the octree
  99531. */
  99532. export interface IOctreeContainer<T> {
  99533. /**
  99534. * Blocks within the octree
  99535. */
  99536. blocks: Array<OctreeBlock<T>>;
  99537. }
  99538. /**
  99539. * Class used to store a cell in an octree
  99540. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99541. */
  99542. export class OctreeBlock<T> {
  99543. /**
  99544. * Gets the content of the current block
  99545. */
  99546. entries: T[];
  99547. /**
  99548. * Gets the list of block children
  99549. */
  99550. blocks: Array<OctreeBlock<T>>;
  99551. private _depth;
  99552. private _maxDepth;
  99553. private _capacity;
  99554. private _minPoint;
  99555. private _maxPoint;
  99556. private _boundingVectors;
  99557. private _creationFunc;
  99558. /**
  99559. * Creates a new block
  99560. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99561. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99562. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99563. * @param depth defines the current depth of this block in the octree
  99564. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99565. * @param creationFunc defines a callback to call when an element is added to the block
  99566. */
  99567. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99568. /**
  99569. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99570. */
  99571. readonly capacity: number;
  99572. /**
  99573. * Gets the minimum vector (in world space) of the block's bounding box
  99574. */
  99575. readonly minPoint: Vector3;
  99576. /**
  99577. * Gets the maximum vector (in world space) of the block's bounding box
  99578. */
  99579. readonly maxPoint: Vector3;
  99580. /**
  99581. * Add a new element to this block
  99582. * @param entry defines the element to add
  99583. */
  99584. addEntry(entry: T): void;
  99585. /**
  99586. * Remove an element from this block
  99587. * @param entry defines the element to remove
  99588. */
  99589. removeEntry(entry: T): void;
  99590. /**
  99591. * Add an array of elements to this block
  99592. * @param entries defines the array of elements to add
  99593. */
  99594. addEntries(entries: T[]): void;
  99595. /**
  99596. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99597. * @param frustumPlanes defines the frustum planes to test
  99598. * @param selection defines the array to store current content if selection is positive
  99599. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99600. */
  99601. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99602. /**
  99603. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99604. * @param sphereCenter defines the bounding sphere center
  99605. * @param sphereRadius defines the bounding sphere radius
  99606. * @param selection defines the array to store current content if selection is positive
  99607. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99608. */
  99609. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99610. /**
  99611. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99612. * @param ray defines the ray to test with
  99613. * @param selection defines the array to store current content if selection is positive
  99614. */
  99615. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99616. /**
  99617. * Subdivide the content into child blocks (this block will then be empty)
  99618. */
  99619. createInnerBlocks(): void;
  99620. /**
  99621. * @hidden
  99622. */
  99623. 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;
  99624. }
  99625. }
  99626. declare module BABYLON {
  99627. /**
  99628. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99629. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99630. */
  99631. export class Octree<T> {
  99632. /** 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.) */
  99633. maxDepth: number;
  99634. /**
  99635. * Blocks within the octree containing objects
  99636. */
  99637. blocks: Array<OctreeBlock<T>>;
  99638. /**
  99639. * Content stored in the octree
  99640. */
  99641. dynamicContent: T[];
  99642. private _maxBlockCapacity;
  99643. private _selectionContent;
  99644. private _creationFunc;
  99645. /**
  99646. * Creates a octree
  99647. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99648. * @param creationFunc function to be used to instatiate the octree
  99649. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99650. * @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.)
  99651. */
  99652. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99653. /** 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.) */
  99654. maxDepth?: number);
  99655. /**
  99656. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99657. * @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);
  99658. * @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);
  99659. * @param entries meshes to be added to the octree blocks
  99660. */
  99661. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99662. /**
  99663. * Adds a mesh to the octree
  99664. * @param entry Mesh to add to the octree
  99665. */
  99666. addMesh(entry: T): void;
  99667. /**
  99668. * Remove an element from the octree
  99669. * @param entry defines the element to remove
  99670. */
  99671. removeMesh(entry: T): void;
  99672. /**
  99673. * Selects an array of meshes within the frustum
  99674. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99675. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99676. * @returns array of meshes within the frustum
  99677. */
  99678. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99679. /**
  99680. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99681. * @param sphereCenter defines the bounding sphere center
  99682. * @param sphereRadius defines the bounding sphere radius
  99683. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99684. * @returns an array of objects that intersect the sphere
  99685. */
  99686. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99687. /**
  99688. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99689. * @param ray defines the ray to test with
  99690. * @returns array of intersected objects
  99691. */
  99692. intersectsRay(ray: Ray): SmartArray<T>;
  99693. /**
  99694. * Adds a mesh into the octree block if it intersects the block
  99695. */
  99696. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99697. /**
  99698. * Adds a submesh into the octree block if it intersects the block
  99699. */
  99700. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99701. }
  99702. }
  99703. declare module BABYLON {
  99704. interface Scene {
  99705. /**
  99706. * @hidden
  99707. * Backing Filed
  99708. */
  99709. _selectionOctree: Octree<AbstractMesh>;
  99710. /**
  99711. * Gets the octree used to boost mesh selection (picking)
  99712. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99713. */
  99714. selectionOctree: Octree<AbstractMesh>;
  99715. /**
  99716. * Creates or updates the octree used to boost selection (picking)
  99717. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99718. * @param maxCapacity defines the maximum capacity per leaf
  99719. * @param maxDepth defines the maximum depth of the octree
  99720. * @returns an octree of AbstractMesh
  99721. */
  99722. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99723. }
  99724. interface AbstractMesh {
  99725. /**
  99726. * @hidden
  99727. * Backing Field
  99728. */
  99729. _submeshesOctree: Octree<SubMesh>;
  99730. /**
  99731. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99732. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99733. * @param maxCapacity defines the maximum size of each block (64 by default)
  99734. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99735. * @returns the new octree
  99736. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99738. */
  99739. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99740. }
  99741. /**
  99742. * Defines the octree scene component responsible to manage any octrees
  99743. * in a given scene.
  99744. */
  99745. export class OctreeSceneComponent {
  99746. /**
  99747. * The component name helpfull to identify the component in the list of scene components.
  99748. */
  99749. readonly name: string;
  99750. /**
  99751. * The scene the component belongs to.
  99752. */
  99753. scene: Scene;
  99754. /**
  99755. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99756. */
  99757. readonly checksIsEnabled: boolean;
  99758. /**
  99759. * Creates a new instance of the component for the given scene
  99760. * @param scene Defines the scene to register the component in
  99761. */
  99762. constructor(scene: Scene);
  99763. /**
  99764. * Registers the component in a given scene
  99765. */
  99766. register(): void;
  99767. /**
  99768. * Return the list of active meshes
  99769. * @returns the list of active meshes
  99770. */
  99771. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99772. /**
  99773. * Return the list of active sub meshes
  99774. * @param mesh The mesh to get the candidates sub meshes from
  99775. * @returns the list of active sub meshes
  99776. */
  99777. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99778. private _tempRay;
  99779. /**
  99780. * Return the list of sub meshes intersecting with a given local ray
  99781. * @param mesh defines the mesh to find the submesh for
  99782. * @param localRay defines the ray in local space
  99783. * @returns the list of intersecting sub meshes
  99784. */
  99785. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99786. /**
  99787. * Return the list of sub meshes colliding with a collider
  99788. * @param mesh defines the mesh to find the submesh for
  99789. * @param collider defines the collider to evaluate the collision against
  99790. * @returns the list of colliding sub meshes
  99791. */
  99792. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99793. /**
  99794. * Rebuilds the elements related to this component in case of
  99795. * context lost for instance.
  99796. */
  99797. rebuild(): void;
  99798. /**
  99799. * Disposes the component and the associated ressources.
  99800. */
  99801. dispose(): void;
  99802. }
  99803. }
  99804. declare module BABYLON {
  99805. /**
  99806. * Renders a layer on top of an existing scene
  99807. */
  99808. export class UtilityLayerRenderer implements IDisposable {
  99809. /** the original scene that will be rendered on top of */
  99810. originalScene: Scene;
  99811. private _pointerCaptures;
  99812. private _lastPointerEvents;
  99813. private static _DefaultUtilityLayer;
  99814. private static _DefaultKeepDepthUtilityLayer;
  99815. private _sharedGizmoLight;
  99816. /**
  99817. * @hidden
  99818. * Light which used by gizmos to get light shading
  99819. */
  99820. _getSharedGizmoLight(): HemisphericLight;
  99821. /**
  99822. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  99823. */
  99824. pickUtilitySceneFirst: boolean;
  99825. /**
  99826. * 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)
  99827. */
  99828. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  99829. /**
  99830. * 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)
  99831. */
  99832. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  99833. /**
  99834. * The scene that is rendered on top of the original scene
  99835. */
  99836. utilityLayerScene: Scene;
  99837. /**
  99838. * If the utility layer should automatically be rendered on top of existing scene
  99839. */
  99840. shouldRender: boolean;
  99841. /**
  99842. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  99843. */
  99844. onlyCheckPointerDownEvents: boolean;
  99845. /**
  99846. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  99847. */
  99848. processAllEvents: boolean;
  99849. /**
  99850. * Observable raised when the pointer move from the utility layer scene to the main scene
  99851. */
  99852. onPointerOutObservable: Observable<number>;
  99853. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  99854. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  99855. private _afterRenderObserver;
  99856. private _sceneDisposeObserver;
  99857. private _originalPointerObserver;
  99858. /**
  99859. * Instantiates a UtilityLayerRenderer
  99860. * @param originalScene the original scene that will be rendered on top of
  99861. * @param handleEvents boolean indicating if the utility layer should handle events
  99862. */
  99863. constructor(
  99864. /** the original scene that will be rendered on top of */
  99865. originalScene: Scene, handleEvents?: boolean);
  99866. private _notifyObservers;
  99867. /**
  99868. * Renders the utility layers scene on top of the original scene
  99869. */
  99870. render(): void;
  99871. /**
  99872. * Disposes of the renderer
  99873. */
  99874. dispose(): void;
  99875. private _updateCamera;
  99876. }
  99877. }
  99878. declare module BABYLON {
  99879. /**
  99880. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  99881. */
  99882. export class Gizmo implements IDisposable {
  99883. /** The utility layer the gizmo will be added to */
  99884. gizmoLayer: UtilityLayerRenderer;
  99885. /**
  99886. * The root mesh of the gizmo
  99887. */
  99888. _rootMesh: Mesh;
  99889. private _attachedMesh;
  99890. /**
  99891. * Ratio for the scale of the gizmo (Default: 1)
  99892. */
  99893. scaleRatio: number;
  99894. private _tmpMatrix;
  99895. /**
  99896. * If a custom mesh has been set (Default: false)
  99897. */
  99898. protected _customMeshSet: boolean;
  99899. /**
  99900. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  99901. * * When set, interactions will be enabled
  99902. */
  99903. attachedMesh: Nullable<AbstractMesh>;
  99904. /**
  99905. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  99906. * @param mesh The mesh to replace the default mesh of the gizmo
  99907. */
  99908. setCustomMesh(mesh: Mesh): void;
  99909. /**
  99910. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  99911. */
  99912. updateGizmoRotationToMatchAttachedMesh: boolean;
  99913. /**
  99914. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  99915. */
  99916. updateGizmoPositionToMatchAttachedMesh: boolean;
  99917. /**
  99918. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  99919. */
  99920. protected _updateScale: boolean;
  99921. protected _interactionsEnabled: boolean;
  99922. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99923. private _beforeRenderObserver;
  99924. /**
  99925. * Creates a gizmo
  99926. * @param gizmoLayer The utility layer the gizmo will be added to
  99927. */
  99928. constructor(
  99929. /** The utility layer the gizmo will be added to */
  99930. gizmoLayer?: UtilityLayerRenderer);
  99931. private _tempVector;
  99932. /**
  99933. * @hidden
  99934. * Updates the gizmo to match the attached mesh's position/rotation
  99935. */
  99936. protected _update(): void;
  99937. /**
  99938. * Disposes of the gizmo
  99939. */
  99940. dispose(): void;
  99941. }
  99942. }
  99943. declare module BABYLON {
  99944. /**
  99945. * Single axis drag gizmo
  99946. */
  99947. export class AxisDragGizmo extends Gizmo {
  99948. /**
  99949. * Drag behavior responsible for the gizmos dragging interactions
  99950. */
  99951. dragBehavior: PointerDragBehavior;
  99952. private _pointerObserver;
  99953. /**
  99954. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  99955. */
  99956. snapDistance: number;
  99957. /**
  99958. * Event that fires each time the gizmo snaps to a new location.
  99959. * * snapDistance is the the change in distance
  99960. */
  99961. onSnapObservable: Observable<{
  99962. snapDistance: number;
  99963. }>;
  99964. /** @hidden */
  99965. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  99966. /** @hidden */
  99967. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  99968. /**
  99969. * Creates an AxisDragGizmo
  99970. * @param gizmoLayer The utility layer the gizmo will be added to
  99971. * @param dragAxis The axis which the gizmo will be able to drag on
  99972. * @param color The color of the gizmo
  99973. */
  99974. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  99975. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  99976. /**
  99977. * Disposes of the gizmo
  99978. */
  99979. dispose(): void;
  99980. }
  99981. }
  99982. declare module BABYLON.Debug {
  99983. /**
  99984. * The Axes viewer will show 3 axes in a specific point in space
  99985. */
  99986. export class AxesViewer {
  99987. private _xAxis;
  99988. private _yAxis;
  99989. private _zAxis;
  99990. private _scaleLinesFactor;
  99991. private _instanced;
  99992. /**
  99993. * Gets the hosting scene
  99994. */
  99995. scene: Scene;
  99996. /**
  99997. * Gets or sets a number used to scale line length
  99998. */
  99999. scaleLines: number;
  100000. /** Gets the node hierarchy used to render x-axis */
  100001. readonly xAxis: TransformNode;
  100002. /** Gets the node hierarchy used to render y-axis */
  100003. readonly yAxis: TransformNode;
  100004. /** Gets the node hierarchy used to render z-axis */
  100005. readonly zAxis: TransformNode;
  100006. /**
  100007. * Creates a new AxesViewer
  100008. * @param scene defines the hosting scene
  100009. * @param scaleLines defines a number used to scale line length (1 by default)
  100010. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100011. * @param xAxis defines the node hierarchy used to render the x-axis
  100012. * @param yAxis defines the node hierarchy used to render the y-axis
  100013. * @param zAxis defines the node hierarchy used to render the z-axis
  100014. */
  100015. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100016. /**
  100017. * Force the viewer to update
  100018. * @param position defines the position of the viewer
  100019. * @param xaxis defines the x axis of the viewer
  100020. * @param yaxis defines the y axis of the viewer
  100021. * @param zaxis defines the z axis of the viewer
  100022. */
  100023. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100024. /**
  100025. * Creates an instance of this axes viewer.
  100026. * @returns a new axes viewer with instanced meshes
  100027. */
  100028. createInstance(): AxesViewer;
  100029. /** Releases resources */
  100030. dispose(): void;
  100031. private static _SetRenderingGroupId;
  100032. }
  100033. }
  100034. declare module BABYLON.Debug {
  100035. /**
  100036. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100037. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100038. */
  100039. export class BoneAxesViewer extends AxesViewer {
  100040. /**
  100041. * Gets or sets the target mesh where to display the axes viewer
  100042. */
  100043. mesh: Nullable<Mesh>;
  100044. /**
  100045. * Gets or sets the target bone where to display the axes viewer
  100046. */
  100047. bone: Nullable<Bone>;
  100048. /** Gets current position */
  100049. pos: Vector3;
  100050. /** Gets direction of X axis */
  100051. xaxis: Vector3;
  100052. /** Gets direction of Y axis */
  100053. yaxis: Vector3;
  100054. /** Gets direction of Z axis */
  100055. zaxis: Vector3;
  100056. /**
  100057. * Creates a new BoneAxesViewer
  100058. * @param scene defines the hosting scene
  100059. * @param bone defines the target bone
  100060. * @param mesh defines the target mesh
  100061. * @param scaleLines defines a scaling factor for line length (1 by default)
  100062. */
  100063. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100064. /**
  100065. * Force the viewer to update
  100066. */
  100067. update(): void;
  100068. /** Releases resources */
  100069. dispose(): void;
  100070. }
  100071. }
  100072. declare module BABYLON {
  100073. /**
  100074. * Interface used to define scene explorer extensibility option
  100075. */
  100076. export interface IExplorerExtensibilityOption {
  100077. /**
  100078. * Define the option label
  100079. */
  100080. label: string;
  100081. /**
  100082. * Defines the action to execute on click
  100083. */
  100084. action: (entity: any) => void;
  100085. }
  100086. /**
  100087. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100088. */
  100089. export interface IExplorerExtensibilityGroup {
  100090. /**
  100091. * Defines a predicate to test if a given type mut be extended
  100092. */
  100093. predicate: (entity: any) => boolean;
  100094. /**
  100095. * Gets the list of options added to a type
  100096. */
  100097. entries: IExplorerExtensibilityOption[];
  100098. }
  100099. /**
  100100. * Interface used to define the options to use to create the Inspector
  100101. */
  100102. export interface IInspectorOptions {
  100103. /**
  100104. * Display in overlay mode (default: false)
  100105. */
  100106. overlay?: boolean;
  100107. /**
  100108. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100109. */
  100110. globalRoot?: HTMLElement;
  100111. /**
  100112. * Display the Scene explorer
  100113. */
  100114. showExplorer?: boolean;
  100115. /**
  100116. * Display the property inspector
  100117. */
  100118. showInspector?: boolean;
  100119. /**
  100120. * Display in embed mode (both panes on the right)
  100121. */
  100122. embedMode?: boolean;
  100123. /**
  100124. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100125. */
  100126. handleResize?: boolean;
  100127. /**
  100128. * Allow the panes to popup (default: true)
  100129. */
  100130. enablePopup?: boolean;
  100131. /**
  100132. * Allow the panes to be closed by users (default: true)
  100133. */
  100134. enableClose?: boolean;
  100135. /**
  100136. * Optional list of extensibility entries
  100137. */
  100138. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100139. /**
  100140. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100141. */
  100142. inspectorURL?: string;
  100143. }
  100144. interface Scene {
  100145. /**
  100146. * @hidden
  100147. * Backing field
  100148. */
  100149. _debugLayer: DebugLayer;
  100150. /**
  100151. * Gets the debug layer (aka Inspector) associated with the scene
  100152. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100153. */
  100154. debugLayer: DebugLayer;
  100155. }
  100156. /**
  100157. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100158. * what is happening in your scene
  100159. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100160. */
  100161. export class DebugLayer {
  100162. /**
  100163. * Define the url to get the inspector script from.
  100164. * By default it uses the babylonjs CDN.
  100165. * @ignoreNaming
  100166. */
  100167. static InspectorURL: string;
  100168. private _scene;
  100169. private BJSINSPECTOR;
  100170. /**
  100171. * Observable triggered when a property is changed through the inspector.
  100172. */
  100173. onPropertyChangedObservable: Observable<{
  100174. object: any;
  100175. property: string;
  100176. value: any;
  100177. initialValue: any;
  100178. }>;
  100179. /**
  100180. * Instantiates a new debug layer.
  100181. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100182. * what is happening in your scene
  100183. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100184. * @param scene Defines the scene to inspect
  100185. */
  100186. constructor(scene: Scene);
  100187. /** Creates the inspector window. */
  100188. private _createInspector;
  100189. /**
  100190. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100191. * @param entity defines the entity to select
  100192. * @param lineContainerTitle defines the specific block to highlight
  100193. */
  100194. select(entity: any, lineContainerTitle?: string): void;
  100195. /** Get the inspector from bundle or global */
  100196. private _getGlobalInspector;
  100197. /**
  100198. * Get if the inspector is visible or not.
  100199. * @returns true if visible otherwise, false
  100200. */
  100201. isVisible(): boolean;
  100202. /**
  100203. * Hide the inspector and close its window.
  100204. */
  100205. hide(): void;
  100206. /**
  100207. * Launch the debugLayer.
  100208. * @param config Define the configuration of the inspector
  100209. * @return a promise fulfilled when the debug layer is visible
  100210. */
  100211. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100212. }
  100213. }
  100214. declare module BABYLON {
  100215. /**
  100216. * Class containing static functions to help procedurally build meshes
  100217. */
  100218. export class BoxBuilder {
  100219. /**
  100220. * Creates a box mesh
  100221. * * The parameter `size` sets the size (float) of each box side (default 1)
  100222. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100223. * * 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)
  100224. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100228. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100229. * @param name defines the name of the mesh
  100230. * @param options defines the options used to create the mesh
  100231. * @param scene defines the hosting scene
  100232. * @returns the box mesh
  100233. */
  100234. static CreateBox(name: string, options: {
  100235. size?: number;
  100236. width?: number;
  100237. height?: number;
  100238. depth?: number;
  100239. faceUV?: Vector4[];
  100240. faceColors?: Color4[];
  100241. sideOrientation?: number;
  100242. frontUVs?: Vector4;
  100243. backUVs?: Vector4;
  100244. wrap?: boolean;
  100245. topBaseAt?: number;
  100246. bottomBaseAt?: number;
  100247. updatable?: boolean;
  100248. }, scene?: Nullable<Scene>): Mesh;
  100249. }
  100250. }
  100251. declare module BABYLON {
  100252. /**
  100253. * Class containing static functions to help procedurally build meshes
  100254. */
  100255. export class SphereBuilder {
  100256. /**
  100257. * Creates a sphere mesh
  100258. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100259. * * 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`)
  100260. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100261. * * 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
  100262. * * 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)
  100263. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100264. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100266. * @param name defines the name of the mesh
  100267. * @param options defines the options used to create the mesh
  100268. * @param scene defines the hosting scene
  100269. * @returns the sphere mesh
  100270. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100271. */
  100272. static CreateSphere(name: string, options: {
  100273. segments?: number;
  100274. diameter?: number;
  100275. diameterX?: number;
  100276. diameterY?: number;
  100277. diameterZ?: number;
  100278. arc?: number;
  100279. slice?: number;
  100280. sideOrientation?: number;
  100281. frontUVs?: Vector4;
  100282. backUVs?: Vector4;
  100283. updatable?: boolean;
  100284. }, scene: any): Mesh;
  100285. }
  100286. }
  100287. declare module BABYLON.Debug {
  100288. /**
  100289. * Used to show the physics impostor around the specific mesh
  100290. */
  100291. export class PhysicsViewer {
  100292. /** @hidden */
  100293. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100294. /** @hidden */
  100295. protected _meshes: Array<Nullable<AbstractMesh>>;
  100296. /** @hidden */
  100297. protected _scene: Nullable<Scene>;
  100298. /** @hidden */
  100299. protected _numMeshes: number;
  100300. /** @hidden */
  100301. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100302. private _renderFunction;
  100303. private _utilityLayer;
  100304. private _debugBoxMesh;
  100305. private _debugSphereMesh;
  100306. private _debugCylinderMesh;
  100307. private _debugMaterial;
  100308. private _debugMeshMeshes;
  100309. /**
  100310. * Creates a new PhysicsViewer
  100311. * @param scene defines the hosting scene
  100312. */
  100313. constructor(scene: Scene);
  100314. /** @hidden */
  100315. protected _updateDebugMeshes(): void;
  100316. /**
  100317. * Renders a specified physic impostor
  100318. * @param impostor defines the impostor to render
  100319. * @param targetMesh defines the mesh represented by the impostor
  100320. * @returns the new debug mesh used to render the impostor
  100321. */
  100322. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100323. /**
  100324. * Hides a specified physic impostor
  100325. * @param impostor defines the impostor to hide
  100326. */
  100327. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100328. private _getDebugMaterial;
  100329. private _getDebugBoxMesh;
  100330. private _getDebugSphereMesh;
  100331. private _getDebugCylinderMesh;
  100332. private _getDebugMeshMesh;
  100333. private _getDebugMesh;
  100334. /** Releases all resources */
  100335. dispose(): void;
  100336. }
  100337. }
  100338. declare module BABYLON {
  100339. /**
  100340. * Class containing static functions to help procedurally build meshes
  100341. */
  100342. export class LinesBuilder {
  100343. /**
  100344. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100345. * * 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
  100346. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100347. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100348. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100349. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100350. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100351. * * 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
  100352. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100355. * @param name defines the name of the new line system
  100356. * @param options defines the options used to create the line system
  100357. * @param scene defines the hosting scene
  100358. * @returns a new line system mesh
  100359. */
  100360. static CreateLineSystem(name: string, options: {
  100361. lines: Vector3[][];
  100362. updatable?: boolean;
  100363. instance?: Nullable<LinesMesh>;
  100364. colors?: Nullable<Color4[][]>;
  100365. useVertexAlpha?: boolean;
  100366. }, scene: Nullable<Scene>): LinesMesh;
  100367. /**
  100368. * Creates a line mesh
  100369. * 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
  100370. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100371. * * The parameter `points` is an array successive Vector3
  100372. * * 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
  100373. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100374. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100375. * * When updating an instance, remember that only point positions can change, not the number of points
  100376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100377. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100378. * @param name defines the name of the new line system
  100379. * @param options defines the options used to create the line system
  100380. * @param scene defines the hosting scene
  100381. * @returns a new line mesh
  100382. */
  100383. static CreateLines(name: string, options: {
  100384. points: Vector3[];
  100385. updatable?: boolean;
  100386. instance?: Nullable<LinesMesh>;
  100387. colors?: Color4[];
  100388. useVertexAlpha?: boolean;
  100389. }, scene?: Nullable<Scene>): LinesMesh;
  100390. /**
  100391. * Creates a dashed line mesh
  100392. * * 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
  100393. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100394. * * The parameter `points` is an array successive Vector3
  100395. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100396. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100397. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100398. * * 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
  100399. * * When updating an instance, remember that only point positions can change, not the number of points
  100400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100401. * @param name defines the name of the mesh
  100402. * @param options defines the options used to create the mesh
  100403. * @param scene defines the hosting scene
  100404. * @returns the dashed line mesh
  100405. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100406. */
  100407. static CreateDashedLines(name: string, options: {
  100408. points: Vector3[];
  100409. dashSize?: number;
  100410. gapSize?: number;
  100411. dashNb?: number;
  100412. updatable?: boolean;
  100413. instance?: LinesMesh;
  100414. }, scene?: Nullable<Scene>): LinesMesh;
  100415. }
  100416. }
  100417. declare module BABYLON {
  100418. /**
  100419. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100420. * in order to better appreciate the issue one might have.
  100421. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100422. */
  100423. export class RayHelper {
  100424. /**
  100425. * Defines the ray we are currently tryin to visualize.
  100426. */
  100427. ray: Nullable<Ray>;
  100428. private _renderPoints;
  100429. private _renderLine;
  100430. private _renderFunction;
  100431. private _scene;
  100432. private _updateToMeshFunction;
  100433. private _attachedToMesh;
  100434. private _meshSpaceDirection;
  100435. private _meshSpaceOrigin;
  100436. /**
  100437. * Helper function to create a colored helper in a scene in one line.
  100438. * @param ray Defines the ray we are currently tryin to visualize
  100439. * @param scene Defines the scene the ray is used in
  100440. * @param color Defines the color we want to see the ray in
  100441. * @returns The newly created ray helper.
  100442. */
  100443. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100444. /**
  100445. * Instantiate a new ray helper.
  100446. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100447. * in order to better appreciate the issue one might have.
  100448. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100449. * @param ray Defines the ray we are currently tryin to visualize
  100450. */
  100451. constructor(ray: Ray);
  100452. /**
  100453. * Shows the ray we are willing to debug.
  100454. * @param scene Defines the scene the ray needs to be rendered in
  100455. * @param color Defines the color the ray needs to be rendered in
  100456. */
  100457. show(scene: Scene, color?: Color3): void;
  100458. /**
  100459. * Hides the ray we are debugging.
  100460. */
  100461. hide(): void;
  100462. private _render;
  100463. /**
  100464. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100465. * @param mesh Defines the mesh we want the helper attached to
  100466. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100467. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100468. * @param length Defines the length of the ray
  100469. */
  100470. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100471. /**
  100472. * Detach the ray helper from the mesh it has previously been attached to.
  100473. */
  100474. detachFromMesh(): void;
  100475. private _updateToMesh;
  100476. /**
  100477. * Dispose the helper and release its associated resources.
  100478. */
  100479. dispose(): void;
  100480. }
  100481. }
  100482. declare module BABYLON.Debug {
  100483. /**
  100484. * Class used to render a debug view of a given skeleton
  100485. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100486. */
  100487. export class SkeletonViewer {
  100488. /** defines the skeleton to render */
  100489. skeleton: Skeleton;
  100490. /** defines the mesh attached to the skeleton */
  100491. mesh: AbstractMesh;
  100492. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100493. autoUpdateBonesMatrices: boolean;
  100494. /** defines the rendering group id to use with the viewer */
  100495. renderingGroupId: number;
  100496. /** Gets or sets the color used to render the skeleton */
  100497. color: Color3;
  100498. private _scene;
  100499. private _debugLines;
  100500. private _debugMesh;
  100501. private _isEnabled;
  100502. private _renderFunction;
  100503. private _utilityLayer;
  100504. /**
  100505. * Returns the mesh used to render the bones
  100506. */
  100507. readonly debugMesh: Nullable<LinesMesh>;
  100508. /**
  100509. * Creates a new SkeletonViewer
  100510. * @param skeleton defines the skeleton to render
  100511. * @param mesh defines the mesh attached to the skeleton
  100512. * @param scene defines the hosting scene
  100513. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100514. * @param renderingGroupId defines the rendering group id to use with the viewer
  100515. */
  100516. constructor(
  100517. /** defines the skeleton to render */
  100518. skeleton: Skeleton,
  100519. /** defines the mesh attached to the skeleton */
  100520. mesh: AbstractMesh, scene: Scene,
  100521. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100522. autoUpdateBonesMatrices?: boolean,
  100523. /** defines the rendering group id to use with the viewer */
  100524. renderingGroupId?: number);
  100525. /** Gets or sets a boolean indicating if the viewer is enabled */
  100526. isEnabled: boolean;
  100527. private _getBonePosition;
  100528. private _getLinesForBonesWithLength;
  100529. private _getLinesForBonesNoLength;
  100530. /** Update the viewer to sync with current skeleton state */
  100531. update(): void;
  100532. /** Release associated resources */
  100533. dispose(): void;
  100534. }
  100535. }
  100536. declare module BABYLON {
  100537. /**
  100538. * Options to create the null engine
  100539. */
  100540. export class NullEngineOptions {
  100541. /**
  100542. * Render width (Default: 512)
  100543. */
  100544. renderWidth: number;
  100545. /**
  100546. * Render height (Default: 256)
  100547. */
  100548. renderHeight: number;
  100549. /**
  100550. * Texture size (Default: 512)
  100551. */
  100552. textureSize: number;
  100553. /**
  100554. * If delta time between frames should be constant
  100555. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100556. */
  100557. deterministicLockstep: boolean;
  100558. /**
  100559. * Maximum about of steps between frames (Default: 4)
  100560. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100561. */
  100562. lockstepMaxSteps: number;
  100563. }
  100564. /**
  100565. * The null engine class provides support for headless version of babylon.js.
  100566. * This can be used in server side scenario or for testing purposes
  100567. */
  100568. export class NullEngine extends Engine {
  100569. private _options;
  100570. /**
  100571. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100572. */
  100573. isDeterministicLockStep(): boolean;
  100574. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100575. getLockstepMaxSteps(): number;
  100576. /**
  100577. * Sets hardware scaling, used to save performance if needed
  100578. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100579. */
  100580. getHardwareScalingLevel(): number;
  100581. constructor(options?: NullEngineOptions);
  100582. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100583. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100584. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100585. getRenderWidth(useScreen?: boolean): number;
  100586. getRenderHeight(useScreen?: boolean): number;
  100587. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100588. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100589. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100590. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100591. bindSamplers(effect: Effect): void;
  100592. enableEffect(effect: Effect): void;
  100593. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100594. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100595. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100596. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100597. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100598. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100599. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100600. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100601. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100602. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100603. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100604. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100605. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100606. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100607. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100608. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100609. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100610. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100611. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100612. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100613. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100614. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100615. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100616. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100617. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100618. bindBuffers(vertexBuffers: {
  100619. [key: string]: VertexBuffer;
  100620. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100621. wipeCaches(bruteForce?: boolean): void;
  100622. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100623. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100624. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100625. /** @hidden */
  100626. _createTexture(): WebGLTexture;
  100627. /** @hidden */
  100628. _releaseTexture(texture: InternalTexture): void;
  100629. 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;
  100630. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100631. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100632. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100633. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100634. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100635. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100636. areAllEffectsReady(): boolean;
  100637. /**
  100638. * @hidden
  100639. * Get the current error code of the webGL context
  100640. * @returns the error code
  100641. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100642. */
  100643. getError(): number;
  100644. /** @hidden */
  100645. _getUnpackAlignement(): number;
  100646. /** @hidden */
  100647. _unpackFlipY(value: boolean): void;
  100648. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100649. /**
  100650. * Updates a dynamic vertex buffer.
  100651. * @param vertexBuffer the vertex buffer to update
  100652. * @param data the data used to update the vertex buffer
  100653. * @param byteOffset the byte offset of the data (optional)
  100654. * @param byteLength the byte length of the data (optional)
  100655. */
  100656. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100657. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100658. /** @hidden */
  100659. _bindTexture(channel: number, texture: InternalTexture): void;
  100660. /** @hidden */
  100661. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100662. releaseEffects(): void;
  100663. displayLoadingUI(): void;
  100664. hideLoadingUI(): void;
  100665. /** @hidden */
  100666. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100667. /** @hidden */
  100668. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100669. /** @hidden */
  100670. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100671. /** @hidden */
  100672. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100673. }
  100674. }
  100675. declare module BABYLON {
  100676. /** @hidden */
  100677. export class _OcclusionDataStorage {
  100678. /** @hidden */
  100679. occlusionInternalRetryCounter: number;
  100680. /** @hidden */
  100681. isOcclusionQueryInProgress: boolean;
  100682. /** @hidden */
  100683. isOccluded: boolean;
  100684. /** @hidden */
  100685. occlusionRetryCount: number;
  100686. /** @hidden */
  100687. occlusionType: number;
  100688. /** @hidden */
  100689. occlusionQueryAlgorithmType: number;
  100690. }
  100691. interface Engine {
  100692. /**
  100693. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100694. * @return the new query
  100695. */
  100696. createQuery(): WebGLQuery;
  100697. /**
  100698. * Delete and release a webGL query
  100699. * @param query defines the query to delete
  100700. * @return the current engine
  100701. */
  100702. deleteQuery(query: WebGLQuery): Engine;
  100703. /**
  100704. * Check if a given query has resolved and got its value
  100705. * @param query defines the query to check
  100706. * @returns true if the query got its value
  100707. */
  100708. isQueryResultAvailable(query: WebGLQuery): boolean;
  100709. /**
  100710. * Gets the value of a given query
  100711. * @param query defines the query to check
  100712. * @returns the value of the query
  100713. */
  100714. getQueryResult(query: WebGLQuery): number;
  100715. /**
  100716. * Initiates an occlusion query
  100717. * @param algorithmType defines the algorithm to use
  100718. * @param query defines the query to use
  100719. * @returns the current engine
  100720. * @see http://doc.babylonjs.com/features/occlusionquery
  100721. */
  100722. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100723. /**
  100724. * Ends an occlusion query
  100725. * @see http://doc.babylonjs.com/features/occlusionquery
  100726. * @param algorithmType defines the algorithm to use
  100727. * @returns the current engine
  100728. */
  100729. endOcclusionQuery(algorithmType: number): Engine;
  100730. /**
  100731. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100732. * Please note that only one query can be issued at a time
  100733. * @returns a time token used to track the time span
  100734. */
  100735. startTimeQuery(): Nullable<_TimeToken>;
  100736. /**
  100737. * Ends a time query
  100738. * @param token defines the token used to measure the time span
  100739. * @returns the time spent (in ns)
  100740. */
  100741. endTimeQuery(token: _TimeToken): int;
  100742. /** @hidden */
  100743. _currentNonTimestampToken: Nullable<_TimeToken>;
  100744. /** @hidden */
  100745. _createTimeQuery(): WebGLQuery;
  100746. /** @hidden */
  100747. _deleteTimeQuery(query: WebGLQuery): void;
  100748. /** @hidden */
  100749. _getGlAlgorithmType(algorithmType: number): number;
  100750. /** @hidden */
  100751. _getTimeQueryResult(query: WebGLQuery): any;
  100752. /** @hidden */
  100753. _getTimeQueryAvailability(query: WebGLQuery): any;
  100754. }
  100755. interface AbstractMesh {
  100756. /**
  100757. * Backing filed
  100758. * @hidden
  100759. */
  100760. __occlusionDataStorage: _OcclusionDataStorage;
  100761. /**
  100762. * Access property
  100763. * @hidden
  100764. */
  100765. _occlusionDataStorage: _OcclusionDataStorage;
  100766. /**
  100767. * 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.
  100768. * The default value is -1 which means don't break the query and wait till the result
  100769. * @see http://doc.babylonjs.com/features/occlusionquery
  100770. */
  100771. occlusionRetryCount: number;
  100772. /**
  100773. * 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:
  100774. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100775. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100776. * * 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.
  100777. * @see http://doc.babylonjs.com/features/occlusionquery
  100778. */
  100779. occlusionType: number;
  100780. /**
  100781. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100782. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100783. * * 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.
  100784. * @see http://doc.babylonjs.com/features/occlusionquery
  100785. */
  100786. occlusionQueryAlgorithmType: number;
  100787. /**
  100788. * 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
  100789. * @see http://doc.babylonjs.com/features/occlusionquery
  100790. */
  100791. isOccluded: boolean;
  100792. /**
  100793. * Flag to check the progress status of the query
  100794. * @see http://doc.babylonjs.com/features/occlusionquery
  100795. */
  100796. isOcclusionQueryInProgress: boolean;
  100797. }
  100798. }
  100799. declare module BABYLON {
  100800. /** @hidden */
  100801. export var _forceTransformFeedbackToBundle: boolean;
  100802. interface Engine {
  100803. /**
  100804. * Creates a webGL transform feedback object
  100805. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  100806. * @returns the webGL transform feedback object
  100807. */
  100808. createTransformFeedback(): WebGLTransformFeedback;
  100809. /**
  100810. * Delete a webGL transform feedback object
  100811. * @param value defines the webGL transform feedback object to delete
  100812. */
  100813. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  100814. /**
  100815. * Bind a webGL transform feedback object to the webgl context
  100816. * @param value defines the webGL transform feedback object to bind
  100817. */
  100818. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  100819. /**
  100820. * Begins a transform feedback operation
  100821. * @param usePoints defines if points or triangles must be used
  100822. */
  100823. beginTransformFeedback(usePoints: boolean): void;
  100824. /**
  100825. * Ends a transform feedback operation
  100826. */
  100827. endTransformFeedback(): void;
  100828. /**
  100829. * Specify the varyings to use with transform feedback
  100830. * @param program defines the associated webGL program
  100831. * @param value defines the list of strings representing the varying names
  100832. */
  100833. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  100834. /**
  100835. * Bind a webGL buffer for a transform feedback operation
  100836. * @param value defines the webGL buffer to bind
  100837. */
  100838. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  100839. }
  100840. }
  100841. declare module BABYLON {
  100842. /**
  100843. * Gather the list of clipboard event types as constants.
  100844. */
  100845. export class ClipboardEventTypes {
  100846. /**
  100847. * The clipboard event is fired when a copy command is active (pressed).
  100848. */
  100849. static readonly COPY: number;
  100850. /**
  100851. * The clipboard event is fired when a cut command is active (pressed).
  100852. */
  100853. static readonly CUT: number;
  100854. /**
  100855. * The clipboard event is fired when a paste command is active (pressed).
  100856. */
  100857. static readonly PASTE: number;
  100858. }
  100859. /**
  100860. * This class is used to store clipboard related info for the onClipboardObservable event.
  100861. */
  100862. export class ClipboardInfo {
  100863. /**
  100864. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100865. */
  100866. type: number;
  100867. /**
  100868. * Defines the related dom event
  100869. */
  100870. event: ClipboardEvent;
  100871. /**
  100872. *Creates an instance of ClipboardInfo.
  100873. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  100874. * @param event Defines the related dom event
  100875. */
  100876. constructor(
  100877. /**
  100878. * Defines the type of event (BABYLON.ClipboardEventTypes)
  100879. */
  100880. type: number,
  100881. /**
  100882. * Defines the related dom event
  100883. */
  100884. event: ClipboardEvent);
  100885. /**
  100886. * Get the clipboard event's type from the keycode.
  100887. * @param keyCode Defines the keyCode for the current keyboard event.
  100888. * @return {number}
  100889. */
  100890. static GetTypeFromCharacter(keyCode: number): number;
  100891. }
  100892. }
  100893. declare module BABYLON {
  100894. /**
  100895. * Class used to represent data loading progression
  100896. */
  100897. export class SceneLoaderProgressEvent {
  100898. /** defines if data length to load can be evaluated */
  100899. readonly lengthComputable: boolean;
  100900. /** defines the loaded data length */
  100901. readonly loaded: number;
  100902. /** defines the data length to load */
  100903. readonly total: number;
  100904. /**
  100905. * Create a new progress event
  100906. * @param lengthComputable defines if data length to load can be evaluated
  100907. * @param loaded defines the loaded data length
  100908. * @param total defines the data length to load
  100909. */
  100910. constructor(
  100911. /** defines if data length to load can be evaluated */
  100912. lengthComputable: boolean,
  100913. /** defines the loaded data length */
  100914. loaded: number,
  100915. /** defines the data length to load */
  100916. total: number);
  100917. /**
  100918. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  100919. * @param event defines the source event
  100920. * @returns a new SceneLoaderProgressEvent
  100921. */
  100922. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  100923. }
  100924. /**
  100925. * Interface used by SceneLoader plugins to define supported file extensions
  100926. */
  100927. export interface ISceneLoaderPluginExtensions {
  100928. /**
  100929. * Defines the list of supported extensions
  100930. */
  100931. [extension: string]: {
  100932. isBinary: boolean;
  100933. };
  100934. }
  100935. /**
  100936. * Interface used by SceneLoader plugin factory
  100937. */
  100938. export interface ISceneLoaderPluginFactory {
  100939. /**
  100940. * Defines the name of the factory
  100941. */
  100942. name: string;
  100943. /**
  100944. * Function called to create a new plugin
  100945. * @return the new plugin
  100946. */
  100947. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  100948. /**
  100949. * Boolean indicating if the plugin can direct load specific data
  100950. */
  100951. canDirectLoad?: (data: string) => boolean;
  100952. }
  100953. /**
  100954. * Interface used to define a SceneLoader plugin
  100955. */
  100956. export interface ISceneLoaderPlugin {
  100957. /**
  100958. * The friendly name of this plugin.
  100959. */
  100960. name: string;
  100961. /**
  100962. * The file extensions supported by this plugin.
  100963. */
  100964. extensions: string | ISceneLoaderPluginExtensions;
  100965. /**
  100966. * Import meshes into a scene.
  100967. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  100968. * @param scene The scene to import into
  100969. * @param data The data to import
  100970. * @param rootUrl The root url for scene and resources
  100971. * @param meshes The meshes array to import into
  100972. * @param particleSystems The particle systems array to import into
  100973. * @param skeletons The skeletons array to import into
  100974. * @param onError The callback when import fails
  100975. * @returns True if successful or false otherwise
  100976. */
  100977. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  100978. /**
  100979. * Load into a scene.
  100980. * @param scene The scene to load into
  100981. * @param data The data to import
  100982. * @param rootUrl The root url for scene and resources
  100983. * @param onError The callback when import fails
  100984. * @returns true if successful or false otherwise
  100985. */
  100986. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  100987. /**
  100988. * The callback that returns true if the data can be directly loaded.
  100989. */
  100990. canDirectLoad?: (data: string) => boolean;
  100991. /**
  100992. * The callback that allows custom handling of the root url based on the response url.
  100993. */
  100994. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  100995. /**
  100996. * Load into an asset container.
  100997. * @param scene The scene to load into
  100998. * @param data The data to import
  100999. * @param rootUrl The root url for scene and resources
  101000. * @param onError The callback when import fails
  101001. * @returns The loaded asset container
  101002. */
  101003. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101004. }
  101005. /**
  101006. * Interface used to define an async SceneLoader plugin
  101007. */
  101008. export interface ISceneLoaderPluginAsync {
  101009. /**
  101010. * The friendly name of this plugin.
  101011. */
  101012. name: string;
  101013. /**
  101014. * The file extensions supported by this plugin.
  101015. */
  101016. extensions: string | ISceneLoaderPluginExtensions;
  101017. /**
  101018. * Import meshes into a scene.
  101019. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101020. * @param scene The scene to import into
  101021. * @param data The data to import
  101022. * @param rootUrl The root url for scene and resources
  101023. * @param onProgress The callback when the load progresses
  101024. * @param fileName Defines the name of the file to load
  101025. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101026. */
  101027. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101028. meshes: AbstractMesh[];
  101029. particleSystems: IParticleSystem[];
  101030. skeletons: Skeleton[];
  101031. animationGroups: AnimationGroup[];
  101032. }>;
  101033. /**
  101034. * Load into a scene.
  101035. * @param scene The scene to load into
  101036. * @param data The data to import
  101037. * @param rootUrl The root url for scene and resources
  101038. * @param onProgress The callback when the load progresses
  101039. * @param fileName Defines the name of the file to load
  101040. * @returns Nothing
  101041. */
  101042. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101043. /**
  101044. * The callback that returns true if the data can be directly loaded.
  101045. */
  101046. canDirectLoad?: (data: string) => boolean;
  101047. /**
  101048. * The callback that allows custom handling of the root url based on the response url.
  101049. */
  101050. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101051. /**
  101052. * Load into an asset container.
  101053. * @param scene The scene to load into
  101054. * @param data The data to import
  101055. * @param rootUrl The root url for scene and resources
  101056. * @param onProgress The callback when the load progresses
  101057. * @param fileName Defines the name of the file to load
  101058. * @returns The loaded asset container
  101059. */
  101060. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101061. }
  101062. /**
  101063. * Class used to load scene from various file formats using registered plugins
  101064. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101065. */
  101066. export class SceneLoader {
  101067. /**
  101068. * No logging while loading
  101069. */
  101070. static readonly NO_LOGGING: number;
  101071. /**
  101072. * Minimal logging while loading
  101073. */
  101074. static readonly MINIMAL_LOGGING: number;
  101075. /**
  101076. * Summary logging while loading
  101077. */
  101078. static readonly SUMMARY_LOGGING: number;
  101079. /**
  101080. * Detailled logging while loading
  101081. */
  101082. static readonly DETAILED_LOGGING: number;
  101083. /**
  101084. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101085. */
  101086. static ForceFullSceneLoadingForIncremental: boolean;
  101087. /**
  101088. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101089. */
  101090. static ShowLoadingScreen: boolean;
  101091. /**
  101092. * Defines the current logging level (while loading the scene)
  101093. * @ignorenaming
  101094. */
  101095. static loggingLevel: number;
  101096. /**
  101097. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101098. */
  101099. static CleanBoneMatrixWeights: boolean;
  101100. /**
  101101. * Event raised when a plugin is used to load a scene
  101102. */
  101103. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101104. private static _registeredPlugins;
  101105. private static _getDefaultPlugin;
  101106. private static _getPluginForExtension;
  101107. private static _getPluginForDirectLoad;
  101108. private static _getPluginForFilename;
  101109. private static _getDirectLoad;
  101110. private static _loadData;
  101111. private static _getFileInfo;
  101112. /**
  101113. * Gets a plugin that can load the given extension
  101114. * @param extension defines the extension to load
  101115. * @returns a plugin or null if none works
  101116. */
  101117. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101118. /**
  101119. * Gets a boolean indicating that the given extension can be loaded
  101120. * @param extension defines the extension to load
  101121. * @returns true if the extension is supported
  101122. */
  101123. static IsPluginForExtensionAvailable(extension: string): boolean;
  101124. /**
  101125. * Adds a new plugin to the list of registered plugins
  101126. * @param plugin defines the plugin to add
  101127. */
  101128. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101129. /**
  101130. * Import meshes into a scene
  101131. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101132. * @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)
  101133. * @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)
  101134. * @param scene the instance of BABYLON.Scene to append to
  101135. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101136. * @param onProgress a callback with a progress event for each file being loaded
  101137. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101138. * @param pluginExtension the extension used to determine the plugin
  101139. * @returns The loaded plugin
  101140. */
  101141. 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>;
  101142. /**
  101143. * Import meshes into a scene
  101144. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101145. * @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)
  101146. * @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)
  101147. * @param scene the instance of BABYLON.Scene to append to
  101148. * @param onProgress a callback with a progress event for each file being loaded
  101149. * @param pluginExtension the extension used to determine the plugin
  101150. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101151. */
  101152. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101153. meshes: AbstractMesh[];
  101154. particleSystems: IParticleSystem[];
  101155. skeletons: Skeleton[];
  101156. animationGroups: AnimationGroup[];
  101157. }>;
  101158. /**
  101159. * Load a scene
  101160. * @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)
  101161. * @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)
  101162. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101163. * @param onSuccess a callback with the scene when import succeeds
  101164. * @param onProgress a callback with a progress event for each file being loaded
  101165. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101166. * @param pluginExtension the extension used to determine the plugin
  101167. * @returns The loaded plugin
  101168. */
  101169. 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>;
  101170. /**
  101171. * Load a scene
  101172. * @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)
  101173. * @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)
  101174. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101175. * @param onProgress a callback with a progress event for each file being loaded
  101176. * @param pluginExtension the extension used to determine the plugin
  101177. * @returns The loaded scene
  101178. */
  101179. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101180. /**
  101181. * Append a scene
  101182. * @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)
  101183. * @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)
  101184. * @param scene is the instance of BABYLON.Scene to append to
  101185. * @param onSuccess a callback with the scene when import succeeds
  101186. * @param onProgress a callback with a progress event for each file being loaded
  101187. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101188. * @param pluginExtension the extension used to determine the plugin
  101189. * @returns The loaded plugin
  101190. */
  101191. 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>;
  101192. /**
  101193. * Append a scene
  101194. * @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)
  101195. * @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)
  101196. * @param scene is the instance of BABYLON.Scene to append to
  101197. * @param onProgress a callback with a progress event for each file being loaded
  101198. * @param pluginExtension the extension used to determine the plugin
  101199. * @returns The given scene
  101200. */
  101201. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101202. /**
  101203. * Load a scene into an asset container
  101204. * @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)
  101205. * @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)
  101206. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101207. * @param onSuccess a callback with the scene when import succeeds
  101208. * @param onProgress a callback with a progress event for each file being loaded
  101209. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101210. * @param pluginExtension the extension used to determine the plugin
  101211. * @returns The loaded plugin
  101212. */
  101213. 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>;
  101214. /**
  101215. * Load a scene into an asset container
  101216. * @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)
  101217. * @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)
  101218. * @param scene is the instance of Scene to append to
  101219. * @param onProgress a callback with a progress event for each file being loaded
  101220. * @param pluginExtension the extension used to determine the plugin
  101221. * @returns The loaded asset container
  101222. */
  101223. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101224. }
  101225. }
  101226. declare module BABYLON {
  101227. /**
  101228. * Google Daydream controller
  101229. */
  101230. export class DaydreamController extends WebVRController {
  101231. /**
  101232. * Base Url for the controller model.
  101233. */
  101234. static MODEL_BASE_URL: string;
  101235. /**
  101236. * File name for the controller model.
  101237. */
  101238. static MODEL_FILENAME: string;
  101239. /**
  101240. * Gamepad Id prefix used to identify Daydream Controller.
  101241. */
  101242. static readonly GAMEPAD_ID_PREFIX: string;
  101243. /**
  101244. * Creates a new DaydreamController from a gamepad
  101245. * @param vrGamepad the gamepad that the controller should be created from
  101246. */
  101247. constructor(vrGamepad: any);
  101248. /**
  101249. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101250. * @param scene scene in which to add meshes
  101251. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101252. */
  101253. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101254. /**
  101255. * Called once for each button that changed state since the last frame
  101256. * @param buttonIdx Which button index changed
  101257. * @param state New state of the button
  101258. * @param changes Which properties on the state changed since last frame
  101259. */
  101260. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101261. }
  101262. }
  101263. declare module BABYLON {
  101264. /**
  101265. * Gear VR Controller
  101266. */
  101267. export class GearVRController extends WebVRController {
  101268. /**
  101269. * Base Url for the controller model.
  101270. */
  101271. static MODEL_BASE_URL: string;
  101272. /**
  101273. * File name for the controller model.
  101274. */
  101275. static MODEL_FILENAME: string;
  101276. /**
  101277. * Gamepad Id prefix used to identify this controller.
  101278. */
  101279. static readonly GAMEPAD_ID_PREFIX: string;
  101280. private readonly _buttonIndexToObservableNameMap;
  101281. /**
  101282. * Creates a new GearVRController from a gamepad
  101283. * @param vrGamepad the gamepad that the controller should be created from
  101284. */
  101285. constructor(vrGamepad: any);
  101286. /**
  101287. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101288. * @param scene scene in which to add meshes
  101289. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101290. */
  101291. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101292. /**
  101293. * Called once for each button that changed state since the last frame
  101294. * @param buttonIdx Which button index changed
  101295. * @param state New state of the button
  101296. * @param changes Which properties on the state changed since last frame
  101297. */
  101298. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101299. }
  101300. }
  101301. declare module BABYLON {
  101302. /**
  101303. * Generic Controller
  101304. */
  101305. export class GenericController extends WebVRController {
  101306. /**
  101307. * Base Url for the controller model.
  101308. */
  101309. static readonly MODEL_BASE_URL: string;
  101310. /**
  101311. * File name for the controller model.
  101312. */
  101313. static readonly MODEL_FILENAME: string;
  101314. /**
  101315. * Creates a new GenericController from a gamepad
  101316. * @param vrGamepad the gamepad that the controller should be created from
  101317. */
  101318. constructor(vrGamepad: any);
  101319. /**
  101320. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101321. * @param scene scene in which to add meshes
  101322. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101323. */
  101324. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101325. /**
  101326. * Called once for each button that changed state since the last frame
  101327. * @param buttonIdx Which button index changed
  101328. * @param state New state of the button
  101329. * @param changes Which properties on the state changed since last frame
  101330. */
  101331. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101332. }
  101333. }
  101334. declare module BABYLON {
  101335. /**
  101336. * Oculus Touch Controller
  101337. */
  101338. export class OculusTouchController extends WebVRController {
  101339. /**
  101340. * Base Url for the controller model.
  101341. */
  101342. static MODEL_BASE_URL: string;
  101343. /**
  101344. * File name for the left controller model.
  101345. */
  101346. static MODEL_LEFT_FILENAME: string;
  101347. /**
  101348. * File name for the right controller model.
  101349. */
  101350. static MODEL_RIGHT_FILENAME: string;
  101351. /**
  101352. * Fired when the secondary trigger on this controller is modified
  101353. */
  101354. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101355. /**
  101356. * Fired when the thumb rest on this controller is modified
  101357. */
  101358. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101359. /**
  101360. * Creates a new OculusTouchController from a gamepad
  101361. * @param vrGamepad the gamepad that the controller should be created from
  101362. */
  101363. constructor(vrGamepad: any);
  101364. /**
  101365. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101366. * @param scene scene in which to add meshes
  101367. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101368. */
  101369. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101370. /**
  101371. * Fired when the A button on this controller is modified
  101372. */
  101373. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101374. /**
  101375. * Fired when the B button on this controller is modified
  101376. */
  101377. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101378. /**
  101379. * Fired when the X button on this controller is modified
  101380. */
  101381. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101382. /**
  101383. * Fired when the Y button on this controller is modified
  101384. */
  101385. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101386. /**
  101387. * Called once for each button that changed state since the last frame
  101388. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101389. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101390. * 2) secondary trigger (same)
  101391. * 3) A (right) X (left), touch, pressed = value
  101392. * 4) B / Y
  101393. * 5) thumb rest
  101394. * @param buttonIdx Which button index changed
  101395. * @param state New state of the button
  101396. * @param changes Which properties on the state changed since last frame
  101397. */
  101398. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101399. }
  101400. }
  101401. declare module BABYLON {
  101402. /**
  101403. * Vive Controller
  101404. */
  101405. export class ViveController extends WebVRController {
  101406. /**
  101407. * Base Url for the controller model.
  101408. */
  101409. static MODEL_BASE_URL: string;
  101410. /**
  101411. * File name for the controller model.
  101412. */
  101413. static MODEL_FILENAME: string;
  101414. /**
  101415. * Creates a new ViveController from a gamepad
  101416. * @param vrGamepad the gamepad that the controller should be created from
  101417. */
  101418. constructor(vrGamepad: any);
  101419. /**
  101420. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101421. * @param scene scene in which to add meshes
  101422. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101423. */
  101424. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101425. /**
  101426. * Fired when the left button on this controller is modified
  101427. */
  101428. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101429. /**
  101430. * Fired when the right button on this controller is modified
  101431. */
  101432. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101433. /**
  101434. * Fired when the menu button on this controller is modified
  101435. */
  101436. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101437. /**
  101438. * Called once for each button that changed state since the last frame
  101439. * Vive mapping:
  101440. * 0: touchpad
  101441. * 1: trigger
  101442. * 2: left AND right buttons
  101443. * 3: menu button
  101444. * @param buttonIdx Which button index changed
  101445. * @param state New state of the button
  101446. * @param changes Which properties on the state changed since last frame
  101447. */
  101448. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101449. }
  101450. }
  101451. declare module BABYLON {
  101452. /**
  101453. * Defines the WindowsMotionController object that the state of the windows motion controller
  101454. */
  101455. export class WindowsMotionController extends WebVRController {
  101456. /**
  101457. * The base url used to load the left and right controller models
  101458. */
  101459. static MODEL_BASE_URL: string;
  101460. /**
  101461. * The name of the left controller model file
  101462. */
  101463. static MODEL_LEFT_FILENAME: string;
  101464. /**
  101465. * The name of the right controller model file
  101466. */
  101467. static MODEL_RIGHT_FILENAME: string;
  101468. /**
  101469. * The controller name prefix for this controller type
  101470. */
  101471. static readonly GAMEPAD_ID_PREFIX: string;
  101472. /**
  101473. * The controller id pattern for this controller type
  101474. */
  101475. private static readonly GAMEPAD_ID_PATTERN;
  101476. private _loadedMeshInfo;
  101477. private readonly _mapping;
  101478. /**
  101479. * Fired when the trackpad on this controller is clicked
  101480. */
  101481. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101482. /**
  101483. * Fired when the trackpad on this controller is modified
  101484. */
  101485. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101486. /**
  101487. * The current x and y values of this controller's trackpad
  101488. */
  101489. trackpad: StickValues;
  101490. /**
  101491. * Creates a new WindowsMotionController from a gamepad
  101492. * @param vrGamepad the gamepad that the controller should be created from
  101493. */
  101494. constructor(vrGamepad: any);
  101495. /**
  101496. * Fired when the trigger on this controller is modified
  101497. */
  101498. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101499. /**
  101500. * Fired when the menu button on this controller is modified
  101501. */
  101502. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101503. /**
  101504. * Fired when the grip button on this controller is modified
  101505. */
  101506. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101507. /**
  101508. * Fired when the thumbstick button on this controller is modified
  101509. */
  101510. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101511. /**
  101512. * Fired when the touchpad button on this controller is modified
  101513. */
  101514. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101515. /**
  101516. * Fired when the touchpad values on this controller are modified
  101517. */
  101518. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101519. private _updateTrackpad;
  101520. /**
  101521. * Called once per frame by the engine.
  101522. */
  101523. update(): void;
  101524. /**
  101525. * Called once for each button that changed state since the last frame
  101526. * @param buttonIdx Which button index changed
  101527. * @param state New state of the button
  101528. * @param changes Which properties on the state changed since last frame
  101529. */
  101530. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101531. /**
  101532. * Moves the buttons on the controller mesh based on their current state
  101533. * @param buttonName the name of the button to move
  101534. * @param buttonValue the value of the button which determines the buttons new position
  101535. */
  101536. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101537. /**
  101538. * Moves the axis on the controller mesh based on its current state
  101539. * @param axis the index of the axis
  101540. * @param axisValue the value of the axis which determines the meshes new position
  101541. * @hidden
  101542. */
  101543. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101544. /**
  101545. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101546. * @param scene scene in which to add meshes
  101547. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101548. */
  101549. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101550. /**
  101551. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101552. * can be transformed by button presses and axes values, based on this._mapping.
  101553. *
  101554. * @param scene scene in which the meshes exist
  101555. * @param meshes list of meshes that make up the controller model to process
  101556. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101557. */
  101558. private processModel;
  101559. private createMeshInfo;
  101560. /**
  101561. * Gets the ray of the controller in the direction the controller is pointing
  101562. * @param length the length the resulting ray should be
  101563. * @returns a ray in the direction the controller is pointing
  101564. */
  101565. getForwardRay(length?: number): Ray;
  101566. /**
  101567. * Disposes of the controller
  101568. */
  101569. dispose(): void;
  101570. }
  101571. }
  101572. declare module BABYLON {
  101573. /**
  101574. * Single axis scale gizmo
  101575. */
  101576. export class AxisScaleGizmo extends Gizmo {
  101577. private _coloredMaterial;
  101578. /**
  101579. * Drag behavior responsible for the gizmos dragging interactions
  101580. */
  101581. dragBehavior: PointerDragBehavior;
  101582. private _pointerObserver;
  101583. /**
  101584. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101585. */
  101586. snapDistance: number;
  101587. /**
  101588. * Event that fires each time the gizmo snaps to a new location.
  101589. * * snapDistance is the the change in distance
  101590. */
  101591. onSnapObservable: Observable<{
  101592. snapDistance: number;
  101593. }>;
  101594. /**
  101595. * If the scaling operation should be done on all axis (default: false)
  101596. */
  101597. uniformScaling: boolean;
  101598. /**
  101599. * Creates an AxisScaleGizmo
  101600. * @param gizmoLayer The utility layer the gizmo will be added to
  101601. * @param dragAxis The axis which the gizmo will be able to scale on
  101602. * @param color The color of the gizmo
  101603. */
  101604. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101605. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101606. /**
  101607. * Disposes of the gizmo
  101608. */
  101609. dispose(): void;
  101610. /**
  101611. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101612. * @param mesh The mesh to replace the default mesh of the gizmo
  101613. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101614. */
  101615. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101616. }
  101617. }
  101618. declare module BABYLON {
  101619. /**
  101620. * Bounding box gizmo
  101621. */
  101622. export class BoundingBoxGizmo extends Gizmo {
  101623. private _lineBoundingBox;
  101624. private _rotateSpheresParent;
  101625. private _scaleBoxesParent;
  101626. private _boundingDimensions;
  101627. private _renderObserver;
  101628. private _pointerObserver;
  101629. private _scaleDragSpeed;
  101630. private _tmpQuaternion;
  101631. private _tmpVector;
  101632. private _tmpRotationMatrix;
  101633. /**
  101634. * 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)
  101635. */
  101636. ignoreChildren: boolean;
  101637. /**
  101638. * 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)
  101639. */
  101640. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101641. /**
  101642. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101643. */
  101644. rotationSphereSize: number;
  101645. /**
  101646. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101647. */
  101648. scaleBoxSize: number;
  101649. /**
  101650. * 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)
  101651. */
  101652. fixedDragMeshScreenSize: boolean;
  101653. /**
  101654. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101655. */
  101656. fixedDragMeshScreenSizeDistanceFactor: number;
  101657. /**
  101658. * Fired when a rotation sphere or scale box is dragged
  101659. */
  101660. onDragStartObservable: Observable<{}>;
  101661. /**
  101662. * Fired when a scale box is dragged
  101663. */
  101664. onScaleBoxDragObservable: Observable<{}>;
  101665. /**
  101666. * Fired when a scale box drag is ended
  101667. */
  101668. onScaleBoxDragEndObservable: Observable<{}>;
  101669. /**
  101670. * Fired when a rotation sphere is dragged
  101671. */
  101672. onRotationSphereDragObservable: Observable<{}>;
  101673. /**
  101674. * Fired when a rotation sphere drag is ended
  101675. */
  101676. onRotationSphereDragEndObservable: Observable<{}>;
  101677. /**
  101678. * 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)
  101679. */
  101680. scalePivot: Nullable<Vector3>;
  101681. /**
  101682. * Mesh used as a pivot to rotate the attached mesh
  101683. */
  101684. private _anchorMesh;
  101685. private _existingMeshScale;
  101686. private _dragMesh;
  101687. private pointerDragBehavior;
  101688. private coloredMaterial;
  101689. private hoverColoredMaterial;
  101690. /**
  101691. * Sets the color of the bounding box gizmo
  101692. * @param color the color to set
  101693. */
  101694. setColor(color: Color3): void;
  101695. /**
  101696. * Creates an BoundingBoxGizmo
  101697. * @param gizmoLayer The utility layer the gizmo will be added to
  101698. * @param color The color of the gizmo
  101699. */
  101700. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101701. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101702. private _selectNode;
  101703. /**
  101704. * Updates the bounding box information for the Gizmo
  101705. */
  101706. updateBoundingBox(): void;
  101707. private _updateRotationSpheres;
  101708. private _updateScaleBoxes;
  101709. /**
  101710. * Enables rotation on the specified axis and disables rotation on the others
  101711. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101712. */
  101713. setEnabledRotationAxis(axis: string): void;
  101714. /**
  101715. * Enables/disables scaling
  101716. * @param enable if scaling should be enabled
  101717. */
  101718. setEnabledScaling(enable: boolean): void;
  101719. private _updateDummy;
  101720. /**
  101721. * Enables a pointer drag behavior on the bounding box of the gizmo
  101722. */
  101723. enableDragBehavior(): void;
  101724. /**
  101725. * Disposes of the gizmo
  101726. */
  101727. dispose(): void;
  101728. /**
  101729. * 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)
  101730. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101731. * @returns the bounding box mesh with the passed in mesh as a child
  101732. */
  101733. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101734. /**
  101735. * CustomMeshes are not supported by this gizmo
  101736. * @param mesh The mesh to replace the default mesh of the gizmo
  101737. */
  101738. setCustomMesh(mesh: Mesh): void;
  101739. }
  101740. }
  101741. declare module BABYLON {
  101742. /**
  101743. * Single plane rotation gizmo
  101744. */
  101745. export class PlaneRotationGizmo extends Gizmo {
  101746. /**
  101747. * Drag behavior responsible for the gizmos dragging interactions
  101748. */
  101749. dragBehavior: PointerDragBehavior;
  101750. private _pointerObserver;
  101751. /**
  101752. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101753. */
  101754. snapDistance: number;
  101755. /**
  101756. * Event that fires each time the gizmo snaps to a new location.
  101757. * * snapDistance is the the change in distance
  101758. */
  101759. onSnapObservable: Observable<{
  101760. snapDistance: number;
  101761. }>;
  101762. /**
  101763. * Creates a PlaneRotationGizmo
  101764. * @param gizmoLayer The utility layer the gizmo will be added to
  101765. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101766. * @param color The color of the gizmo
  101767. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101768. */
  101769. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101770. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101771. /**
  101772. * Disposes of the gizmo
  101773. */
  101774. dispose(): void;
  101775. }
  101776. }
  101777. declare module BABYLON {
  101778. /**
  101779. * Gizmo that enables rotating a mesh along 3 axis
  101780. */
  101781. export class RotationGizmo extends Gizmo {
  101782. /**
  101783. * Internal gizmo used for interactions on the x axis
  101784. */
  101785. xGizmo: PlaneRotationGizmo;
  101786. /**
  101787. * Internal gizmo used for interactions on the y axis
  101788. */
  101789. yGizmo: PlaneRotationGizmo;
  101790. /**
  101791. * Internal gizmo used for interactions on the z axis
  101792. */
  101793. zGizmo: PlaneRotationGizmo;
  101794. /** Fires an event when any of it's sub gizmos are dragged */
  101795. onDragStartObservable: Observable<{}>;
  101796. /** Fires an event when any of it's sub gizmos are released from dragging */
  101797. onDragEndObservable: Observable<{}>;
  101798. attachedMesh: Nullable<AbstractMesh>;
  101799. /**
  101800. * Creates a RotationGizmo
  101801. * @param gizmoLayer The utility layer the gizmo will be added to
  101802. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101803. */
  101804. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101805. updateGizmoRotationToMatchAttachedMesh: boolean;
  101806. /**
  101807. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101808. */
  101809. snapDistance: number;
  101810. /**
  101811. * Ratio for the scale of the gizmo (Default: 1)
  101812. */
  101813. scaleRatio: number;
  101814. /**
  101815. * Disposes of the gizmo
  101816. */
  101817. dispose(): void;
  101818. /**
  101819. * CustomMeshes are not supported by this gizmo
  101820. * @param mesh The mesh to replace the default mesh of the gizmo
  101821. */
  101822. setCustomMesh(mesh: Mesh): void;
  101823. }
  101824. }
  101825. declare module BABYLON {
  101826. /**
  101827. * Gizmo that enables dragging a mesh along 3 axis
  101828. */
  101829. export class PositionGizmo extends Gizmo {
  101830. /**
  101831. * Internal gizmo used for interactions on the x axis
  101832. */
  101833. xGizmo: AxisDragGizmo;
  101834. /**
  101835. * Internal gizmo used for interactions on the y axis
  101836. */
  101837. yGizmo: AxisDragGizmo;
  101838. /**
  101839. * Internal gizmo used for interactions on the z axis
  101840. */
  101841. zGizmo: AxisDragGizmo;
  101842. /** Fires an event when any of it's sub gizmos are dragged */
  101843. onDragStartObservable: Observable<{}>;
  101844. /** Fires an event when any of it's sub gizmos are released from dragging */
  101845. onDragEndObservable: Observable<{}>;
  101846. attachedMesh: Nullable<AbstractMesh>;
  101847. /**
  101848. * Creates a PositionGizmo
  101849. * @param gizmoLayer The utility layer the gizmo will be added to
  101850. */
  101851. constructor(gizmoLayer?: UtilityLayerRenderer);
  101852. updateGizmoRotationToMatchAttachedMesh: boolean;
  101853. /**
  101854. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101855. */
  101856. snapDistance: number;
  101857. /**
  101858. * Ratio for the scale of the gizmo (Default: 1)
  101859. */
  101860. scaleRatio: number;
  101861. /**
  101862. * Disposes of the gizmo
  101863. */
  101864. dispose(): void;
  101865. /**
  101866. * CustomMeshes are not supported by this gizmo
  101867. * @param mesh The mesh to replace the default mesh of the gizmo
  101868. */
  101869. setCustomMesh(mesh: Mesh): void;
  101870. }
  101871. }
  101872. declare module BABYLON {
  101873. /**
  101874. * Class containing static functions to help procedurally build meshes
  101875. */
  101876. export class PolyhedronBuilder {
  101877. /**
  101878. * Creates a polyhedron mesh
  101879. * * 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
  101880. * * The parameter `size` (positive float, default 1) sets the polygon size
  101881. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  101882. * * 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`
  101883. * * 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
  101884. * * 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)`)
  101885. * * 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
  101886. * * 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
  101887. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101890. * @param name defines the name of the mesh
  101891. * @param options defines the options used to create the mesh
  101892. * @param scene defines the hosting scene
  101893. * @returns the polyhedron mesh
  101894. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  101895. */
  101896. static CreatePolyhedron(name: string, options: {
  101897. type?: number;
  101898. size?: number;
  101899. sizeX?: number;
  101900. sizeY?: number;
  101901. sizeZ?: number;
  101902. custom?: any;
  101903. faceUV?: Vector4[];
  101904. faceColors?: Color4[];
  101905. flat?: boolean;
  101906. updatable?: boolean;
  101907. sideOrientation?: number;
  101908. frontUVs?: Vector4;
  101909. backUVs?: Vector4;
  101910. }, scene?: Nullable<Scene>): Mesh;
  101911. }
  101912. }
  101913. declare module BABYLON {
  101914. /**
  101915. * Gizmo that enables scaling a mesh along 3 axis
  101916. */
  101917. export class ScaleGizmo extends Gizmo {
  101918. /**
  101919. * Internal gizmo used for interactions on the x axis
  101920. */
  101921. xGizmo: AxisScaleGizmo;
  101922. /**
  101923. * Internal gizmo used for interactions on the y axis
  101924. */
  101925. yGizmo: AxisScaleGizmo;
  101926. /**
  101927. * Internal gizmo used for interactions on the z axis
  101928. */
  101929. zGizmo: AxisScaleGizmo;
  101930. /**
  101931. * Internal gizmo used to scale all axis equally
  101932. */
  101933. uniformScaleGizmo: AxisScaleGizmo;
  101934. /** Fires an event when any of it's sub gizmos are dragged */
  101935. onDragStartObservable: Observable<{}>;
  101936. /** Fires an event when any of it's sub gizmos are released from dragging */
  101937. onDragEndObservable: Observable<{}>;
  101938. attachedMesh: Nullable<AbstractMesh>;
  101939. /**
  101940. * Creates a ScaleGizmo
  101941. * @param gizmoLayer The utility layer the gizmo will be added to
  101942. */
  101943. constructor(gizmoLayer?: UtilityLayerRenderer);
  101944. updateGizmoRotationToMatchAttachedMesh: boolean;
  101945. /**
  101946. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101947. */
  101948. snapDistance: number;
  101949. /**
  101950. * Ratio for the scale of the gizmo (Default: 1)
  101951. */
  101952. scaleRatio: number;
  101953. /**
  101954. * Disposes of the gizmo
  101955. */
  101956. dispose(): void;
  101957. }
  101958. }
  101959. declare module BABYLON {
  101960. /**
  101961. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  101962. */
  101963. export class GizmoManager implements IDisposable {
  101964. private scene;
  101965. /**
  101966. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  101967. */
  101968. gizmos: {
  101969. positionGizmo: Nullable<PositionGizmo>;
  101970. rotationGizmo: Nullable<RotationGizmo>;
  101971. scaleGizmo: Nullable<ScaleGizmo>;
  101972. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  101973. };
  101974. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  101975. clearGizmoOnEmptyPointerEvent: boolean;
  101976. /** Fires an event when the manager is attached to a mesh */
  101977. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  101978. private _gizmosEnabled;
  101979. private _pointerObserver;
  101980. private _attachedMesh;
  101981. private _boundingBoxColor;
  101982. private _defaultUtilityLayer;
  101983. private _defaultKeepDepthUtilityLayer;
  101984. /**
  101985. * When bounding box gizmo is enabled, this can be used to track drag/end events
  101986. */
  101987. boundingBoxDragBehavior: SixDofDragBehavior;
  101988. /**
  101989. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  101990. */
  101991. attachableMeshes: Nullable<Array<AbstractMesh>>;
  101992. /**
  101993. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  101994. */
  101995. usePointerToAttachGizmos: boolean;
  101996. /**
  101997. * Instatiates a gizmo manager
  101998. * @param scene the scene to overlay the gizmos on top of
  101999. */
  102000. constructor(scene: Scene);
  102001. /**
  102002. * Attaches a set of gizmos to the specified mesh
  102003. * @param mesh The mesh the gizmo's should be attached to
  102004. */
  102005. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102006. /**
  102007. * If the position gizmo is enabled
  102008. */
  102009. positionGizmoEnabled: boolean;
  102010. /**
  102011. * If the rotation gizmo is enabled
  102012. */
  102013. rotationGizmoEnabled: boolean;
  102014. /**
  102015. * If the scale gizmo is enabled
  102016. */
  102017. scaleGizmoEnabled: boolean;
  102018. /**
  102019. * If the boundingBox gizmo is enabled
  102020. */
  102021. boundingBoxGizmoEnabled: boolean;
  102022. /**
  102023. * Disposes of the gizmo manager
  102024. */
  102025. dispose(): void;
  102026. }
  102027. }
  102028. declare module BABYLON {
  102029. /**
  102030. * A directional light is defined by a direction (what a surprise!).
  102031. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102032. * 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.
  102033. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102034. */
  102035. export class DirectionalLight extends ShadowLight {
  102036. private _shadowFrustumSize;
  102037. /**
  102038. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102039. */
  102040. /**
  102041. * Specifies a fix frustum size for the shadow generation.
  102042. */
  102043. shadowFrustumSize: number;
  102044. private _shadowOrthoScale;
  102045. /**
  102046. * Gets the shadow projection scale against the optimal computed one.
  102047. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102048. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102049. */
  102050. /**
  102051. * Sets the shadow projection scale against the optimal computed one.
  102052. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102053. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102054. */
  102055. shadowOrthoScale: number;
  102056. /**
  102057. * Automatically compute the projection matrix to best fit (including all the casters)
  102058. * on each frame.
  102059. */
  102060. autoUpdateExtends: boolean;
  102061. private _orthoLeft;
  102062. private _orthoRight;
  102063. private _orthoTop;
  102064. private _orthoBottom;
  102065. /**
  102066. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102067. * The directional light is emitted from everywhere in the given direction.
  102068. * It can cast shadows.
  102069. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102070. * @param name The friendly name of the light
  102071. * @param direction The direction of the light
  102072. * @param scene The scene the light belongs to
  102073. */
  102074. constructor(name: string, direction: Vector3, scene: Scene);
  102075. /**
  102076. * Returns the string "DirectionalLight".
  102077. * @return The class name
  102078. */
  102079. getClassName(): string;
  102080. /**
  102081. * Returns the integer 1.
  102082. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102083. */
  102084. getTypeID(): number;
  102085. /**
  102086. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102087. * Returns the DirectionalLight Shadow projection matrix.
  102088. */
  102089. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102090. /**
  102091. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102092. * Returns the DirectionalLight Shadow projection matrix.
  102093. */
  102094. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102095. /**
  102096. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102097. * Returns the DirectionalLight Shadow projection matrix.
  102098. */
  102099. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102100. protected _buildUniformLayout(): void;
  102101. /**
  102102. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102103. * @param effect The effect to update
  102104. * @param lightIndex The index of the light in the effect to update
  102105. * @returns The directional light
  102106. */
  102107. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102108. /**
  102109. * Gets the minZ used for shadow according to both the scene and the light.
  102110. *
  102111. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102112. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102113. * @param activeCamera The camera we are returning the min for
  102114. * @returns the depth min z
  102115. */
  102116. getDepthMinZ(activeCamera: Camera): number;
  102117. /**
  102118. * Gets the maxZ used for shadow according to both the scene and the light.
  102119. *
  102120. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102121. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102122. * @param activeCamera The camera we are returning the max for
  102123. * @returns the depth max z
  102124. */
  102125. getDepthMaxZ(activeCamera: Camera): number;
  102126. /**
  102127. * Prepares the list of defines specific to the light type.
  102128. * @param defines the list of defines
  102129. * @param lightIndex defines the index of the light for the effect
  102130. */
  102131. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102132. }
  102133. }
  102134. declare module BABYLON {
  102135. /**
  102136. * Class containing static functions to help procedurally build meshes
  102137. */
  102138. export class HemisphereBuilder {
  102139. /**
  102140. * Creates a hemisphere mesh
  102141. * @param name defines the name of the mesh
  102142. * @param options defines the options used to create the mesh
  102143. * @param scene defines the hosting scene
  102144. * @returns the hemisphere mesh
  102145. */
  102146. static CreateHemisphere(name: string, options: {
  102147. segments?: number;
  102148. diameter?: number;
  102149. sideOrientation?: number;
  102150. }, scene: any): Mesh;
  102151. }
  102152. }
  102153. declare module BABYLON {
  102154. /**
  102155. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102156. * These values define a cone of light starting from the position, emitting toward the direction.
  102157. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102158. * and the exponent defines the speed of the decay of the light with distance (reach).
  102159. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102160. */
  102161. export class SpotLight extends ShadowLight {
  102162. private _angle;
  102163. private _innerAngle;
  102164. private _cosHalfAngle;
  102165. private _lightAngleScale;
  102166. private _lightAngleOffset;
  102167. /**
  102168. * Gets the cone angle of the spot light in Radians.
  102169. */
  102170. /**
  102171. * Sets the cone angle of the spot light in Radians.
  102172. */
  102173. angle: number;
  102174. /**
  102175. * Only used in gltf falloff mode, this defines the angle where
  102176. * the directional falloff will start before cutting at angle which could be seen
  102177. * as outer angle.
  102178. */
  102179. /**
  102180. * Only used in gltf falloff mode, this defines the angle where
  102181. * the directional falloff will start before cutting at angle which could be seen
  102182. * as outer angle.
  102183. */
  102184. innerAngle: number;
  102185. private _shadowAngleScale;
  102186. /**
  102187. * Allows scaling the angle of the light for shadow generation only.
  102188. */
  102189. /**
  102190. * Allows scaling the angle of the light for shadow generation only.
  102191. */
  102192. shadowAngleScale: number;
  102193. /**
  102194. * The light decay speed with the distance from the emission spot.
  102195. */
  102196. exponent: number;
  102197. private _projectionTextureMatrix;
  102198. /**
  102199. * Allows reading the projecton texture
  102200. */
  102201. readonly projectionTextureMatrix: Matrix;
  102202. protected _projectionTextureLightNear: number;
  102203. /**
  102204. * Gets the near clip of the Spotlight for texture projection.
  102205. */
  102206. /**
  102207. * Sets the near clip of the Spotlight for texture projection.
  102208. */
  102209. projectionTextureLightNear: number;
  102210. protected _projectionTextureLightFar: number;
  102211. /**
  102212. * Gets the far clip of the Spotlight for texture projection.
  102213. */
  102214. /**
  102215. * Sets the far clip of the Spotlight for texture projection.
  102216. */
  102217. projectionTextureLightFar: number;
  102218. protected _projectionTextureUpDirection: Vector3;
  102219. /**
  102220. * Gets the Up vector of the Spotlight for texture projection.
  102221. */
  102222. /**
  102223. * Sets the Up vector of the Spotlight for texture projection.
  102224. */
  102225. projectionTextureUpDirection: Vector3;
  102226. private _projectionTexture;
  102227. /**
  102228. * Gets the projection texture of the light.
  102229. */
  102230. /**
  102231. * Sets the projection texture of the light.
  102232. */
  102233. projectionTexture: Nullable<BaseTexture>;
  102234. private _projectionTextureViewLightDirty;
  102235. private _projectionTextureProjectionLightDirty;
  102236. private _projectionTextureDirty;
  102237. private _projectionTextureViewTargetVector;
  102238. private _projectionTextureViewLightMatrix;
  102239. private _projectionTextureProjectionLightMatrix;
  102240. private _projectionTextureScalingMatrix;
  102241. /**
  102242. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102243. * It can cast shadows.
  102244. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102245. * @param name The light friendly name
  102246. * @param position The position of the spot light in the scene
  102247. * @param direction The direction of the light in the scene
  102248. * @param angle The cone angle of the light in Radians
  102249. * @param exponent The light decay speed with the distance from the emission spot
  102250. * @param scene The scene the lights belongs to
  102251. */
  102252. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102253. /**
  102254. * Returns the string "SpotLight".
  102255. * @returns the class name
  102256. */
  102257. getClassName(): string;
  102258. /**
  102259. * Returns the integer 2.
  102260. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102261. */
  102262. getTypeID(): number;
  102263. /**
  102264. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102265. */
  102266. protected _setDirection(value: Vector3): void;
  102267. /**
  102268. * Overrides the position setter to recompute the projection texture view light Matrix.
  102269. */
  102270. protected _setPosition(value: Vector3): void;
  102271. /**
  102272. * 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.
  102273. * Returns the SpotLight.
  102274. */
  102275. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102276. protected _computeProjectionTextureViewLightMatrix(): void;
  102277. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102278. /**
  102279. * Main function for light texture projection matrix computing.
  102280. */
  102281. protected _computeProjectionTextureMatrix(): void;
  102282. protected _buildUniformLayout(): void;
  102283. private _computeAngleValues;
  102284. /**
  102285. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102286. * @param effect The effect to update
  102287. * @param lightIndex The index of the light in the effect to update
  102288. * @returns The spot light
  102289. */
  102290. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102291. /**
  102292. * Disposes the light and the associated resources.
  102293. */
  102294. dispose(): void;
  102295. /**
  102296. * Prepares the list of defines specific to the light type.
  102297. * @param defines the list of defines
  102298. * @param lightIndex defines the index of the light for the effect
  102299. */
  102300. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102301. }
  102302. }
  102303. declare module BABYLON {
  102304. /**
  102305. * Gizmo that enables viewing a light
  102306. */
  102307. export class LightGizmo extends Gizmo {
  102308. private _lightMesh;
  102309. private _material;
  102310. /**
  102311. * Creates a LightGizmo
  102312. * @param gizmoLayer The utility layer the gizmo will be added to
  102313. */
  102314. constructor(gizmoLayer?: UtilityLayerRenderer);
  102315. private _light;
  102316. /**
  102317. * The light that the gizmo is attached to
  102318. */
  102319. light: Nullable<Light>;
  102320. /**
  102321. * @hidden
  102322. * Updates the gizmo to match the attached mesh's position/rotation
  102323. */
  102324. protected _update(): void;
  102325. private static _Scale;
  102326. /**
  102327. * Creates the lines for a light mesh
  102328. */
  102329. private static _createLightLines;
  102330. private static _CreateHemisphericLightMesh;
  102331. private static _CreatePointLightMesh;
  102332. private static _CreateSpotLightMesh;
  102333. private static _CreateDirectionalLightMesh;
  102334. }
  102335. }
  102336. declare module BABYLON {
  102337. /** @hidden */
  102338. export var backgroundFragmentDeclaration: {
  102339. name: string;
  102340. shader: string;
  102341. };
  102342. }
  102343. declare module BABYLON {
  102344. /** @hidden */
  102345. export var backgroundUboDeclaration: {
  102346. name: string;
  102347. shader: string;
  102348. };
  102349. }
  102350. declare module BABYLON {
  102351. /** @hidden */
  102352. export var backgroundPixelShader: {
  102353. name: string;
  102354. shader: string;
  102355. };
  102356. }
  102357. declare module BABYLON {
  102358. /** @hidden */
  102359. export var backgroundVertexDeclaration: {
  102360. name: string;
  102361. shader: string;
  102362. };
  102363. }
  102364. declare module BABYLON {
  102365. /** @hidden */
  102366. export var backgroundVertexShader: {
  102367. name: string;
  102368. shader: string;
  102369. };
  102370. }
  102371. declare module BABYLON {
  102372. /**
  102373. * Background material used to create an efficient environement around your scene.
  102374. */
  102375. export class BackgroundMaterial extends PushMaterial {
  102376. /**
  102377. * Standard reflectance value at parallel view angle.
  102378. */
  102379. static StandardReflectance0: number;
  102380. /**
  102381. * Standard reflectance value at grazing angle.
  102382. */
  102383. static StandardReflectance90: number;
  102384. protected _primaryColor: Color3;
  102385. /**
  102386. * Key light Color (multiply against the environement texture)
  102387. */
  102388. primaryColor: Color3;
  102389. protected __perceptualColor: Nullable<Color3>;
  102390. /**
  102391. * Experimental Internal Use Only.
  102392. *
  102393. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102394. * This acts as a helper to set the primary color to a more "human friendly" value.
  102395. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102396. * output color as close as possible from the chosen value.
  102397. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102398. * part of lighting setup.)
  102399. */
  102400. _perceptualColor: Nullable<Color3>;
  102401. protected _primaryColorShadowLevel: float;
  102402. /**
  102403. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102404. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102405. */
  102406. primaryColorShadowLevel: float;
  102407. protected _primaryColorHighlightLevel: float;
  102408. /**
  102409. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102410. * The primary color is used at the level chosen to define what the white area would look.
  102411. */
  102412. primaryColorHighlightLevel: float;
  102413. protected _reflectionTexture: Nullable<BaseTexture>;
  102414. /**
  102415. * Reflection Texture used in the material.
  102416. * Should be author in a specific way for the best result (refer to the documentation).
  102417. */
  102418. reflectionTexture: Nullable<BaseTexture>;
  102419. protected _reflectionBlur: float;
  102420. /**
  102421. * Reflection Texture level of blur.
  102422. *
  102423. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102424. * texture twice.
  102425. */
  102426. reflectionBlur: float;
  102427. protected _diffuseTexture: Nullable<BaseTexture>;
  102428. /**
  102429. * Diffuse Texture used in the material.
  102430. * Should be author in a specific way for the best result (refer to the documentation).
  102431. */
  102432. diffuseTexture: Nullable<BaseTexture>;
  102433. protected _shadowLights: Nullable<IShadowLight[]>;
  102434. /**
  102435. * Specify the list of lights casting shadow on the material.
  102436. * All scene shadow lights will be included if null.
  102437. */
  102438. shadowLights: Nullable<IShadowLight[]>;
  102439. protected _shadowLevel: float;
  102440. /**
  102441. * Helps adjusting the shadow to a softer level if required.
  102442. * 0 means black shadows and 1 means no shadows.
  102443. */
  102444. shadowLevel: float;
  102445. protected _sceneCenter: Vector3;
  102446. /**
  102447. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102448. * It is usually zero but might be interesting to modify according to your setup.
  102449. */
  102450. sceneCenter: Vector3;
  102451. protected _opacityFresnel: boolean;
  102452. /**
  102453. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102454. * This helps ensuring a nice transition when the camera goes under the ground.
  102455. */
  102456. opacityFresnel: boolean;
  102457. protected _reflectionFresnel: boolean;
  102458. /**
  102459. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102460. * This helps adding a mirror texture on the ground.
  102461. */
  102462. reflectionFresnel: boolean;
  102463. protected _reflectionFalloffDistance: number;
  102464. /**
  102465. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102466. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102467. */
  102468. reflectionFalloffDistance: number;
  102469. protected _reflectionAmount: number;
  102470. /**
  102471. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102472. */
  102473. reflectionAmount: number;
  102474. protected _reflectionReflectance0: number;
  102475. /**
  102476. * This specifies the weight of the reflection at grazing angle.
  102477. */
  102478. reflectionReflectance0: number;
  102479. protected _reflectionReflectance90: number;
  102480. /**
  102481. * This specifies the weight of the reflection at a perpendicular point of view.
  102482. */
  102483. reflectionReflectance90: number;
  102484. /**
  102485. * Sets the reflection reflectance fresnel values according to the default standard
  102486. * empirically know to work well :-)
  102487. */
  102488. reflectionStandardFresnelWeight: number;
  102489. protected _useRGBColor: boolean;
  102490. /**
  102491. * Helps to directly use the maps channels instead of their level.
  102492. */
  102493. useRGBColor: boolean;
  102494. protected _enableNoise: boolean;
  102495. /**
  102496. * This helps reducing the banding effect that could occur on the background.
  102497. */
  102498. enableNoise: boolean;
  102499. /**
  102500. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102501. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102502. * Recommended to be keep at 1.0 except for special cases.
  102503. */
  102504. fovMultiplier: number;
  102505. private _fovMultiplier;
  102506. /**
  102507. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102508. */
  102509. useEquirectangularFOV: boolean;
  102510. private _maxSimultaneousLights;
  102511. /**
  102512. * Number of Simultaneous lights allowed on the material.
  102513. */
  102514. maxSimultaneousLights: int;
  102515. /**
  102516. * Default configuration related to image processing available in the Background Material.
  102517. */
  102518. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102519. /**
  102520. * Keep track of the image processing observer to allow dispose and replace.
  102521. */
  102522. private _imageProcessingObserver;
  102523. /**
  102524. * Attaches a new image processing configuration to the PBR Material.
  102525. * @param configuration (if null the scene configuration will be use)
  102526. */
  102527. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102528. /**
  102529. * Gets the image processing configuration used either in this material.
  102530. */
  102531. /**
  102532. * Sets the Default image processing configuration used either in the this material.
  102533. *
  102534. * If sets to null, the scene one is in use.
  102535. */
  102536. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102537. /**
  102538. * Gets wether the color curves effect is enabled.
  102539. */
  102540. /**
  102541. * Sets wether the color curves effect is enabled.
  102542. */
  102543. cameraColorCurvesEnabled: boolean;
  102544. /**
  102545. * Gets wether the color grading effect is enabled.
  102546. */
  102547. /**
  102548. * Gets wether the color grading effect is enabled.
  102549. */
  102550. cameraColorGradingEnabled: boolean;
  102551. /**
  102552. * Gets wether tonemapping is enabled or not.
  102553. */
  102554. /**
  102555. * Sets wether tonemapping is enabled or not
  102556. */
  102557. cameraToneMappingEnabled: boolean;
  102558. /**
  102559. * The camera exposure used on this material.
  102560. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102561. * This corresponds to a photographic exposure.
  102562. */
  102563. /**
  102564. * The camera exposure used on this material.
  102565. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102566. * This corresponds to a photographic exposure.
  102567. */
  102568. cameraExposure: float;
  102569. /**
  102570. * Gets The camera contrast used on this material.
  102571. */
  102572. /**
  102573. * Sets The camera contrast used on this material.
  102574. */
  102575. cameraContrast: float;
  102576. /**
  102577. * Gets the Color Grading 2D Lookup Texture.
  102578. */
  102579. /**
  102580. * Sets the Color Grading 2D Lookup Texture.
  102581. */
  102582. cameraColorGradingTexture: Nullable<BaseTexture>;
  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. /**
  102590. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102591. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102592. * 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;
  102593. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102594. */
  102595. cameraColorCurves: Nullable<ColorCurves>;
  102596. /**
  102597. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102598. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102599. */
  102600. switchToBGR: boolean;
  102601. private _renderTargets;
  102602. private _reflectionControls;
  102603. private _white;
  102604. private _primaryShadowColor;
  102605. private _primaryHighlightColor;
  102606. /**
  102607. * Instantiates a Background Material in the given scene
  102608. * @param name The friendly name of the material
  102609. * @param scene The scene to add the material to
  102610. */
  102611. constructor(name: string, scene: Scene);
  102612. /**
  102613. * Gets a boolean indicating that current material needs to register RTT
  102614. */
  102615. readonly hasRenderTargetTextures: boolean;
  102616. /**
  102617. * The entire material has been created in order to prevent overdraw.
  102618. * @returns false
  102619. */
  102620. needAlphaTesting(): boolean;
  102621. /**
  102622. * The entire material has been created in order to prevent overdraw.
  102623. * @returns true if blending is enable
  102624. */
  102625. needAlphaBlending(): boolean;
  102626. /**
  102627. * Checks wether the material is ready to be rendered for a given mesh.
  102628. * @param mesh The mesh to render
  102629. * @param subMesh The submesh to check against
  102630. * @param useInstances Specify wether or not the material is used with instances
  102631. * @returns true if all the dependencies are ready (Textures, Effects...)
  102632. */
  102633. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102634. /**
  102635. * Compute the primary color according to the chosen perceptual color.
  102636. */
  102637. private _computePrimaryColorFromPerceptualColor;
  102638. /**
  102639. * Compute the highlights and shadow colors according to their chosen levels.
  102640. */
  102641. private _computePrimaryColors;
  102642. /**
  102643. * Build the uniform buffer used in the material.
  102644. */
  102645. buildUniformLayout(): void;
  102646. /**
  102647. * Unbind the material.
  102648. */
  102649. unbind(): void;
  102650. /**
  102651. * Bind only the world matrix to the material.
  102652. * @param world The world matrix to bind.
  102653. */
  102654. bindOnlyWorldMatrix(world: Matrix): void;
  102655. /**
  102656. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102657. * @param world The world matrix to bind.
  102658. * @param subMesh The submesh to bind for.
  102659. */
  102660. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102661. /**
  102662. * Dispose the material.
  102663. * @param forceDisposeEffect Force disposal of the associated effect.
  102664. * @param forceDisposeTextures Force disposal of the associated textures.
  102665. */
  102666. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102667. /**
  102668. * Clones the material.
  102669. * @param name The cloned name.
  102670. * @returns The cloned material.
  102671. */
  102672. clone(name: string): BackgroundMaterial;
  102673. /**
  102674. * Serializes the current material to its JSON representation.
  102675. * @returns The JSON representation.
  102676. */
  102677. serialize(): any;
  102678. /**
  102679. * Gets the class name of the material
  102680. * @returns "BackgroundMaterial"
  102681. */
  102682. getClassName(): string;
  102683. /**
  102684. * Parse a JSON input to create back a background material.
  102685. * @param source The JSON data to parse
  102686. * @param scene The scene to create the parsed material in
  102687. * @param rootUrl The root url of the assets the material depends upon
  102688. * @returns the instantiated BackgroundMaterial.
  102689. */
  102690. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102691. }
  102692. }
  102693. declare module BABYLON {
  102694. /**
  102695. * Represents the different options available during the creation of
  102696. * a Environment helper.
  102697. *
  102698. * This can control the default ground, skybox and image processing setup of your scene.
  102699. */
  102700. export interface IEnvironmentHelperOptions {
  102701. /**
  102702. * Specifies wether or not to create a ground.
  102703. * True by default.
  102704. */
  102705. createGround: boolean;
  102706. /**
  102707. * Specifies the ground size.
  102708. * 15 by default.
  102709. */
  102710. groundSize: number;
  102711. /**
  102712. * The texture used on the ground for the main color.
  102713. * Comes from the BabylonJS CDN by default.
  102714. *
  102715. * Remarks: Can be either a texture or a url.
  102716. */
  102717. groundTexture: string | BaseTexture;
  102718. /**
  102719. * The color mixed in the ground texture by default.
  102720. * BabylonJS clearColor by default.
  102721. */
  102722. groundColor: Color3;
  102723. /**
  102724. * Specifies the ground opacity.
  102725. * 1 by default.
  102726. */
  102727. groundOpacity: number;
  102728. /**
  102729. * Enables the ground to receive shadows.
  102730. * True by default.
  102731. */
  102732. enableGroundShadow: boolean;
  102733. /**
  102734. * Helps preventing the shadow to be fully black on the ground.
  102735. * 0.5 by default.
  102736. */
  102737. groundShadowLevel: number;
  102738. /**
  102739. * Creates a mirror texture attach to the ground.
  102740. * false by default.
  102741. */
  102742. enableGroundMirror: boolean;
  102743. /**
  102744. * Specifies the ground mirror size ratio.
  102745. * 0.3 by default as the default kernel is 64.
  102746. */
  102747. groundMirrorSizeRatio: number;
  102748. /**
  102749. * Specifies the ground mirror blur kernel size.
  102750. * 64 by default.
  102751. */
  102752. groundMirrorBlurKernel: number;
  102753. /**
  102754. * Specifies the ground mirror visibility amount.
  102755. * 1 by default
  102756. */
  102757. groundMirrorAmount: number;
  102758. /**
  102759. * Specifies the ground mirror reflectance weight.
  102760. * This uses the standard weight of the background material to setup the fresnel effect
  102761. * of the mirror.
  102762. * 1 by default.
  102763. */
  102764. groundMirrorFresnelWeight: number;
  102765. /**
  102766. * Specifies the ground mirror Falloff distance.
  102767. * This can helps reducing the size of the reflection.
  102768. * 0 by Default.
  102769. */
  102770. groundMirrorFallOffDistance: number;
  102771. /**
  102772. * Specifies the ground mirror texture type.
  102773. * Unsigned Int by Default.
  102774. */
  102775. groundMirrorTextureType: number;
  102776. /**
  102777. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102778. * the shown objects.
  102779. */
  102780. groundYBias: number;
  102781. /**
  102782. * Specifies wether or not to create a skybox.
  102783. * True by default.
  102784. */
  102785. createSkybox: boolean;
  102786. /**
  102787. * Specifies the skybox size.
  102788. * 20 by default.
  102789. */
  102790. skyboxSize: number;
  102791. /**
  102792. * The texture used on the skybox for the main color.
  102793. * Comes from the BabylonJS CDN by default.
  102794. *
  102795. * Remarks: Can be either a texture or a url.
  102796. */
  102797. skyboxTexture: string | BaseTexture;
  102798. /**
  102799. * The color mixed in the skybox texture by default.
  102800. * BabylonJS clearColor by default.
  102801. */
  102802. skyboxColor: Color3;
  102803. /**
  102804. * The background rotation around the Y axis of the scene.
  102805. * This helps aligning the key lights of your scene with the background.
  102806. * 0 by default.
  102807. */
  102808. backgroundYRotation: number;
  102809. /**
  102810. * Compute automatically the size of the elements to best fit with the scene.
  102811. */
  102812. sizeAuto: boolean;
  102813. /**
  102814. * Default position of the rootMesh if autoSize is not true.
  102815. */
  102816. rootPosition: Vector3;
  102817. /**
  102818. * Sets up the image processing in the scene.
  102819. * true by default.
  102820. */
  102821. setupImageProcessing: boolean;
  102822. /**
  102823. * The texture used as your environment texture in the scene.
  102824. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  102825. *
  102826. * Remarks: Can be either a texture or a url.
  102827. */
  102828. environmentTexture: string | BaseTexture;
  102829. /**
  102830. * The value of the exposure to apply to the scene.
  102831. * 0.6 by default if setupImageProcessing is true.
  102832. */
  102833. cameraExposure: number;
  102834. /**
  102835. * The value of the contrast to apply to the scene.
  102836. * 1.6 by default if setupImageProcessing is true.
  102837. */
  102838. cameraContrast: number;
  102839. /**
  102840. * Specifies wether or not tonemapping should be enabled in the scene.
  102841. * true by default if setupImageProcessing is true.
  102842. */
  102843. toneMappingEnabled: boolean;
  102844. }
  102845. /**
  102846. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  102847. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  102848. * It also helps with the default setup of your imageProcessing configuration.
  102849. */
  102850. export class EnvironmentHelper {
  102851. /**
  102852. * Default ground texture URL.
  102853. */
  102854. private static _groundTextureCDNUrl;
  102855. /**
  102856. * Default skybox texture URL.
  102857. */
  102858. private static _skyboxTextureCDNUrl;
  102859. /**
  102860. * Default environment texture URL.
  102861. */
  102862. private static _environmentTextureCDNUrl;
  102863. /**
  102864. * Creates the default options for the helper.
  102865. */
  102866. private static _getDefaultOptions;
  102867. private _rootMesh;
  102868. /**
  102869. * Gets the root mesh created by the helper.
  102870. */
  102871. readonly rootMesh: Mesh;
  102872. private _skybox;
  102873. /**
  102874. * Gets the skybox created by the helper.
  102875. */
  102876. readonly skybox: Nullable<Mesh>;
  102877. private _skyboxTexture;
  102878. /**
  102879. * Gets the skybox texture created by the helper.
  102880. */
  102881. readonly skyboxTexture: Nullable<BaseTexture>;
  102882. private _skyboxMaterial;
  102883. /**
  102884. * Gets the skybox material created by the helper.
  102885. */
  102886. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  102887. private _ground;
  102888. /**
  102889. * Gets the ground mesh created by the helper.
  102890. */
  102891. readonly ground: Nullable<Mesh>;
  102892. private _groundTexture;
  102893. /**
  102894. * Gets the ground texture created by the helper.
  102895. */
  102896. readonly groundTexture: Nullable<BaseTexture>;
  102897. private _groundMirror;
  102898. /**
  102899. * Gets the ground mirror created by the helper.
  102900. */
  102901. readonly groundMirror: Nullable<MirrorTexture>;
  102902. /**
  102903. * Gets the ground mirror render list to helps pushing the meshes
  102904. * you wish in the ground reflection.
  102905. */
  102906. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  102907. private _groundMaterial;
  102908. /**
  102909. * Gets the ground material created by the helper.
  102910. */
  102911. readonly groundMaterial: Nullable<BackgroundMaterial>;
  102912. /**
  102913. * Stores the creation options.
  102914. */
  102915. private readonly _scene;
  102916. private _options;
  102917. /**
  102918. * This observable will be notified with any error during the creation of the environment,
  102919. * mainly texture creation errors.
  102920. */
  102921. onErrorObservable: Observable<{
  102922. message?: string;
  102923. exception?: any;
  102924. }>;
  102925. /**
  102926. * constructor
  102927. * @param options Defines the options we want to customize the helper
  102928. * @param scene The scene to add the material to
  102929. */
  102930. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  102931. /**
  102932. * Updates the background according to the new options
  102933. * @param options
  102934. */
  102935. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  102936. /**
  102937. * Sets the primary color of all the available elements.
  102938. * @param color the main color to affect to the ground and the background
  102939. */
  102940. setMainColor(color: Color3): void;
  102941. /**
  102942. * Setup the image processing according to the specified options.
  102943. */
  102944. private _setupImageProcessing;
  102945. /**
  102946. * Setup the environment texture according to the specified options.
  102947. */
  102948. private _setupEnvironmentTexture;
  102949. /**
  102950. * Setup the background according to the specified options.
  102951. */
  102952. private _setupBackground;
  102953. /**
  102954. * Get the scene sizes according to the setup.
  102955. */
  102956. private _getSceneSize;
  102957. /**
  102958. * Setup the ground according to the specified options.
  102959. */
  102960. private _setupGround;
  102961. /**
  102962. * Setup the ground material according to the specified options.
  102963. */
  102964. private _setupGroundMaterial;
  102965. /**
  102966. * Setup the ground diffuse texture according to the specified options.
  102967. */
  102968. private _setupGroundDiffuseTexture;
  102969. /**
  102970. * Setup the ground mirror texture according to the specified options.
  102971. */
  102972. private _setupGroundMirrorTexture;
  102973. /**
  102974. * Setup the ground to receive the mirror texture.
  102975. */
  102976. private _setupMirrorInGroundMaterial;
  102977. /**
  102978. * Setup the skybox according to the specified options.
  102979. */
  102980. private _setupSkybox;
  102981. /**
  102982. * Setup the skybox material according to the specified options.
  102983. */
  102984. private _setupSkyboxMaterial;
  102985. /**
  102986. * Setup the skybox reflection texture according to the specified options.
  102987. */
  102988. private _setupSkyboxReflectionTexture;
  102989. private _errorHandler;
  102990. /**
  102991. * Dispose all the elements created by the Helper.
  102992. */
  102993. dispose(): void;
  102994. }
  102995. }
  102996. declare module BABYLON {
  102997. /**
  102998. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  102999. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103000. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103001. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103002. */
  103003. export class PhotoDome extends TransformNode {
  103004. private _useDirectMapping;
  103005. /**
  103006. * The texture being displayed on the sphere
  103007. */
  103008. protected _photoTexture: Texture;
  103009. /**
  103010. * Gets or sets the texture being displayed on the sphere
  103011. */
  103012. photoTexture: Texture;
  103013. /**
  103014. * Observable raised when an error occured while loading the 360 image
  103015. */
  103016. onLoadErrorObservable: Observable<string>;
  103017. /**
  103018. * The skybox material
  103019. */
  103020. protected _material: BackgroundMaterial;
  103021. /**
  103022. * The surface used for the skybox
  103023. */
  103024. protected _mesh: Mesh;
  103025. /**
  103026. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103027. * Also see the options.resolution property.
  103028. */
  103029. fovMultiplier: number;
  103030. /**
  103031. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103032. * @param name Element's name, child elements will append suffixes for their own names.
  103033. * @param urlsOfPhoto defines the url of the photo to display
  103034. * @param options defines an object containing optional or exposed sub element properties
  103035. * @param onError defines a callback called when an error occured while loading the texture
  103036. */
  103037. constructor(name: string, urlOfPhoto: string, options: {
  103038. resolution?: number;
  103039. size?: number;
  103040. useDirectMapping?: boolean;
  103041. faceForward?: boolean;
  103042. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103043. /**
  103044. * Releases resources associated with this node.
  103045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103047. */
  103048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103049. }
  103050. }
  103051. declare module BABYLON {
  103052. /** @hidden */
  103053. export var rgbdDecodePixelShader: {
  103054. name: string;
  103055. shader: string;
  103056. };
  103057. }
  103058. declare module BABYLON {
  103059. /**
  103060. * Class used to host texture specific utilities
  103061. */
  103062. export class BRDFTextureTools {
  103063. /**
  103064. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103065. * @param texture the texture to expand.
  103066. */
  103067. private static _ExpandDefaultBRDFTexture;
  103068. /**
  103069. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103070. * @param scene defines the hosting scene
  103071. * @returns the environment BRDF texture
  103072. */
  103073. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103074. private static _environmentBRDFBase64Texture;
  103075. }
  103076. }
  103077. declare module BABYLON {
  103078. /**
  103079. * @hidden
  103080. */
  103081. export interface IMaterialClearCoatDefines {
  103082. CLEARCOAT: boolean;
  103083. CLEARCOAT_DEFAULTIOR: boolean;
  103084. CLEARCOAT_TEXTURE: boolean;
  103085. CLEARCOAT_TEXTUREDIRECTUV: number;
  103086. CLEARCOAT_BUMP: boolean;
  103087. CLEARCOAT_BUMPDIRECTUV: number;
  103088. CLEARCOAT_TINT: boolean;
  103089. CLEARCOAT_TINT_TEXTURE: boolean;
  103090. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103091. /** @hidden */
  103092. _areTexturesDirty: boolean;
  103093. }
  103094. /**
  103095. * Define the code related to the clear coat parameters of the pbr material.
  103096. */
  103097. export class PBRClearCoatConfiguration {
  103098. /**
  103099. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103100. * The default fits with a polyurethane material.
  103101. */
  103102. private static readonly _DefaultIndiceOfRefraction;
  103103. private _isEnabled;
  103104. /**
  103105. * Defines if the clear coat is enabled in the material.
  103106. */
  103107. isEnabled: boolean;
  103108. /**
  103109. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103110. */
  103111. intensity: number;
  103112. /**
  103113. * Defines the clear coat layer roughness.
  103114. */
  103115. roughness: number;
  103116. private _indiceOfRefraction;
  103117. /**
  103118. * Defines the indice of refraction of the clear coat.
  103119. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103120. * The default fits with a polyurethane material.
  103121. * Changing the default value is more performance intensive.
  103122. */
  103123. indiceOfRefraction: number;
  103124. private _texture;
  103125. /**
  103126. * Stores the clear coat values in a texture.
  103127. */
  103128. texture: Nullable<BaseTexture>;
  103129. private _bumpTexture;
  103130. /**
  103131. * Define the clear coat specific bump texture.
  103132. */
  103133. bumpTexture: Nullable<BaseTexture>;
  103134. private _isTintEnabled;
  103135. /**
  103136. * Defines if the clear coat tint is enabled in the material.
  103137. */
  103138. isTintEnabled: boolean;
  103139. /**
  103140. * Defines the clear coat tint of the material.
  103141. * This is only use if tint is enabled
  103142. */
  103143. tintColor: Color3;
  103144. /**
  103145. * Defines the distance at which the tint color should be found in the
  103146. * clear coat media.
  103147. * This is only use if tint is enabled
  103148. */
  103149. tintColorAtDistance: number;
  103150. /**
  103151. * Defines the clear coat layer thickness.
  103152. * This is only use if tint is enabled
  103153. */
  103154. tintThickness: number;
  103155. private _tintTexture;
  103156. /**
  103157. * Stores the clear tint values in a texture.
  103158. * rgb is tint
  103159. * a is a thickness factor
  103160. */
  103161. tintTexture: Nullable<BaseTexture>;
  103162. /** @hidden */
  103163. private _internalMarkAllSubMeshesAsTexturesDirty;
  103164. /** @hidden */
  103165. _markAllSubMeshesAsTexturesDirty(): void;
  103166. /**
  103167. * Instantiate a new istance of clear coat configuration.
  103168. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103169. */
  103170. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103171. /**
  103172. * Gets wehter the submesh is ready to be used or not.
  103173. * @param defines the list of "defines" to update.
  103174. * @param scene defines the scene the material belongs to.
  103175. * @param engine defines the engine the material belongs to.
  103176. * @param disableBumpMap defines wether the material disables bump or not.
  103177. * @returns - boolean indicating that the submesh is ready or not.
  103178. */
  103179. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103180. /**
  103181. * Checks to see if a texture is used in the material.
  103182. * @param defines the list of "defines" to update.
  103183. * @param scene defines the scene to the material belongs to.
  103184. */
  103185. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103186. /**
  103187. * Binds the material data.
  103188. * @param uniformBuffer defines the Uniform buffer to fill in.
  103189. * @param scene defines the scene the material belongs to.
  103190. * @param engine defines the engine the material belongs to.
  103191. * @param disableBumpMap defines wether the material disables bump or not.
  103192. * @param isFrozen defines wether the material is frozen or not.
  103193. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103194. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103195. */
  103196. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103197. /**
  103198. * Checks to see if a texture is used in the material.
  103199. * @param texture - Base texture to use.
  103200. * @returns - Boolean specifying if a texture is used in the material.
  103201. */
  103202. hasTexture(texture: BaseTexture): boolean;
  103203. /**
  103204. * Returns an array of the actively used textures.
  103205. * @param activeTextures Array of BaseTextures
  103206. */
  103207. getActiveTextures(activeTextures: BaseTexture[]): void;
  103208. /**
  103209. * Returns the animatable textures.
  103210. * @param animatables Array of animatable textures.
  103211. */
  103212. getAnimatables(animatables: IAnimatable[]): void;
  103213. /**
  103214. * Disposes the resources of the material.
  103215. * @param forceDisposeTextures - Forces the disposal of all textures.
  103216. */
  103217. dispose(forceDisposeTextures?: boolean): void;
  103218. /**
  103219. * Get the current class name of the texture useful for serialization or dynamic coding.
  103220. * @returns "PBRClearCoatConfiguration"
  103221. */
  103222. getClassName(): string;
  103223. /**
  103224. * Add fallbacks to the effect fallbacks list.
  103225. * @param defines defines the Base texture to use.
  103226. * @param fallbacks defines the current fallback list.
  103227. * @param currentRank defines the current fallback rank.
  103228. * @returns the new fallback rank.
  103229. */
  103230. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103231. /**
  103232. * Add the required uniforms to the current list.
  103233. * @param uniforms defines the current uniform list.
  103234. */
  103235. static AddUniforms(uniforms: string[]): void;
  103236. /**
  103237. * Add the required samplers to the current list.
  103238. * @param samplers defines the current sampler list.
  103239. */
  103240. static AddSamplers(samplers: string[]): void;
  103241. /**
  103242. * Add the required uniforms to the current buffer.
  103243. * @param uniformBuffer defines the current uniform buffer.
  103244. */
  103245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103246. /**
  103247. * Makes a duplicate of the current configuration into another one.
  103248. * @param clearCoatConfiguration define the config where to copy the info
  103249. */
  103250. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103251. /**
  103252. * Serializes this clear coat configuration.
  103253. * @returns - An object with the serialized config.
  103254. */
  103255. serialize(): any;
  103256. /**
  103257. * Parses a Clear Coat Configuration from a serialized object.
  103258. * @param source - Serialized object.
  103259. */
  103260. parse(source: any): void;
  103261. }
  103262. }
  103263. declare module BABYLON {
  103264. /**
  103265. * @hidden
  103266. */
  103267. export interface IMaterialAnisotropicDefines {
  103268. ANISOTROPIC: boolean;
  103269. ANISOTROPIC_TEXTURE: boolean;
  103270. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103271. MAINUV1: boolean;
  103272. _areTexturesDirty: boolean;
  103273. _needUVs: boolean;
  103274. }
  103275. /**
  103276. * Define the code related to the anisotropic parameters of the pbr material.
  103277. */
  103278. export class PBRAnisotropicConfiguration {
  103279. private _isEnabled;
  103280. /**
  103281. * Defines if the anisotropy is enabled in the material.
  103282. */
  103283. isEnabled: boolean;
  103284. /**
  103285. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103286. */
  103287. intensity: number;
  103288. /**
  103289. * Defines if the effect is along the tangents, bitangents or in between.
  103290. * By default, the effect is "strectching" the highlights along the tangents.
  103291. */
  103292. direction: Vector2;
  103293. private _texture;
  103294. /**
  103295. * Stores the anisotropy values in a texture.
  103296. * rg is direction (like normal from -1 to 1)
  103297. * b is a intensity
  103298. */
  103299. texture: Nullable<BaseTexture>;
  103300. /** @hidden */
  103301. private _internalMarkAllSubMeshesAsTexturesDirty;
  103302. /** @hidden */
  103303. _markAllSubMeshesAsTexturesDirty(): void;
  103304. /**
  103305. * Instantiate a new istance of anisotropy configuration.
  103306. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103307. */
  103308. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103309. /**
  103310. * Specifies that the submesh is ready to be used.
  103311. * @param defines the list of "defines" to update.
  103312. * @param scene defines the scene the material belongs to.
  103313. * @returns - boolean indicating that the submesh is ready or not.
  103314. */
  103315. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103316. /**
  103317. * Checks to see if a texture is used in the material.
  103318. * @param defines the list of "defines" to update.
  103319. * @param mesh the mesh we are preparing the defines for.
  103320. * @param scene defines the scene the material belongs to.
  103321. */
  103322. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103323. /**
  103324. * Binds the material data.
  103325. * @param uniformBuffer defines the Uniform buffer to fill in.
  103326. * @param scene defines the scene the material belongs to.
  103327. * @param isFrozen defines wether the material is frozen or not.
  103328. */
  103329. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103330. /**
  103331. * Checks to see if a texture is used in the material.
  103332. * @param texture - Base texture to use.
  103333. * @returns - Boolean specifying if a texture is used in the material.
  103334. */
  103335. hasTexture(texture: BaseTexture): boolean;
  103336. /**
  103337. * Returns an array of the actively used textures.
  103338. * @param activeTextures Array of BaseTextures
  103339. */
  103340. getActiveTextures(activeTextures: BaseTexture[]): void;
  103341. /**
  103342. * Returns the animatable textures.
  103343. * @param animatables Array of animatable textures.
  103344. */
  103345. getAnimatables(animatables: IAnimatable[]): void;
  103346. /**
  103347. * Disposes the resources of the material.
  103348. * @param forceDisposeTextures - Forces the disposal of all textures.
  103349. */
  103350. dispose(forceDisposeTextures?: boolean): void;
  103351. /**
  103352. * Get the current class name of the texture useful for serialization or dynamic coding.
  103353. * @returns "PBRAnisotropicConfiguration"
  103354. */
  103355. getClassName(): string;
  103356. /**
  103357. * Add fallbacks to the effect fallbacks list.
  103358. * @param defines defines the Base texture to use.
  103359. * @param fallbacks defines the current fallback list.
  103360. * @param currentRank defines the current fallback rank.
  103361. * @returns the new fallback rank.
  103362. */
  103363. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103364. /**
  103365. * Add the required uniforms to the current list.
  103366. * @param uniforms defines the current uniform list.
  103367. */
  103368. static AddUniforms(uniforms: string[]): void;
  103369. /**
  103370. * Add the required uniforms to the current buffer.
  103371. * @param uniformBuffer defines the current uniform buffer.
  103372. */
  103373. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103374. /**
  103375. * Add the required samplers to the current list.
  103376. * @param samplers defines the current sampler list.
  103377. */
  103378. static AddSamplers(samplers: string[]): void;
  103379. /**
  103380. * Makes a duplicate of the current configuration into another one.
  103381. * @param anisotropicConfiguration define the config where to copy the info
  103382. */
  103383. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103384. /**
  103385. * Serializes this anisotropy configuration.
  103386. * @returns - An object with the serialized config.
  103387. */
  103388. serialize(): any;
  103389. /**
  103390. * Parses a anisotropy Configuration from a serialized object.
  103391. * @param source - Serialized object.
  103392. */
  103393. parse(source: any): void;
  103394. }
  103395. }
  103396. declare module BABYLON {
  103397. /**
  103398. * @hidden
  103399. */
  103400. export interface IMaterialBRDFDefines {
  103401. BRDF_V_HEIGHT_CORRELATED: boolean;
  103402. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103403. /** @hidden */
  103404. _areMiscDirty: boolean;
  103405. }
  103406. /**
  103407. * Define the code related to the BRDF parameters of the pbr material.
  103408. */
  103409. export class PBRBRDFConfiguration {
  103410. /**
  103411. * Default value used for the energy conservation.
  103412. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103413. */
  103414. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103415. /**
  103416. * Default value used for the Smith Visibility Height Correlated mode.
  103417. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103418. */
  103419. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103420. private _useEnergyConservation;
  103421. /**
  103422. * Defines if the material uses energy conservation.
  103423. */
  103424. useEnergyConservation: boolean;
  103425. private _useSmithVisibilityHeightCorrelated;
  103426. /**
  103427. * LEGACY Mode set to false
  103428. * Defines if the material uses height smith correlated visibility term.
  103429. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103430. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103431. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103432. * Not relying on height correlated will also disable energy conservation.
  103433. */
  103434. useSmithVisibilityHeightCorrelated: boolean;
  103435. /** @hidden */
  103436. private _internalMarkAllSubMeshesAsMiscDirty;
  103437. /** @hidden */
  103438. _markAllSubMeshesAsMiscDirty(): void;
  103439. /**
  103440. * Instantiate a new istance of clear coat configuration.
  103441. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103442. */
  103443. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103444. /**
  103445. * Checks to see if a texture is used in the material.
  103446. * @param defines the list of "defines" to update.
  103447. */
  103448. prepareDefines(defines: IMaterialBRDFDefines): void;
  103449. /**
  103450. * Get the current class name of the texture useful for serialization or dynamic coding.
  103451. * @returns "PBRClearCoatConfiguration"
  103452. */
  103453. getClassName(): string;
  103454. /**
  103455. * Makes a duplicate of the current configuration into another one.
  103456. * @param brdfConfiguration define the config where to copy the info
  103457. */
  103458. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103459. /**
  103460. * Serializes this BRDF configuration.
  103461. * @returns - An object with the serialized config.
  103462. */
  103463. serialize(): any;
  103464. /**
  103465. * Parses a BRDF Configuration from a serialized object.
  103466. * @param source - Serialized object.
  103467. */
  103468. parse(source: any): void;
  103469. }
  103470. }
  103471. declare module BABYLON {
  103472. /**
  103473. * @hidden
  103474. */
  103475. export interface IMaterialSheenDefines {
  103476. SHEEN: boolean;
  103477. SHEEN_TEXTURE: boolean;
  103478. SHEEN_TEXTUREDIRECTUV: number;
  103479. SHEEN_LINKWITHALBEDO: boolean;
  103480. /** @hidden */
  103481. _areTexturesDirty: boolean;
  103482. }
  103483. /**
  103484. * Define the code related to the Sheen parameters of the pbr material.
  103485. */
  103486. export class PBRSheenConfiguration {
  103487. private _isEnabled;
  103488. /**
  103489. * Defines if the material uses sheen.
  103490. */
  103491. isEnabled: boolean;
  103492. private _linkSheenWithAlbedo;
  103493. /**
  103494. * Defines if the sheen is linked to the sheen color.
  103495. */
  103496. linkSheenWithAlbedo: boolean;
  103497. /**
  103498. * Defines the sheen intensity.
  103499. */
  103500. intensity: number;
  103501. /**
  103502. * Defines the sheen color.
  103503. */
  103504. color: Color3;
  103505. private _texture;
  103506. /**
  103507. * Stores the sheen tint values in a texture.
  103508. * rgb is tint
  103509. * a is a intensity
  103510. */
  103511. texture: Nullable<BaseTexture>;
  103512. /** @hidden */
  103513. private _internalMarkAllSubMeshesAsTexturesDirty;
  103514. /** @hidden */
  103515. _markAllSubMeshesAsTexturesDirty(): void;
  103516. /**
  103517. * Instantiate a new istance of clear coat configuration.
  103518. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103519. */
  103520. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103521. /**
  103522. * Specifies that the submesh is ready to be used.
  103523. * @param defines the list of "defines" to update.
  103524. * @param scene defines the scene the material belongs to.
  103525. * @returns - boolean indicating that the submesh is ready or not.
  103526. */
  103527. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103528. /**
  103529. * Checks to see if a texture is used in the material.
  103530. * @param defines the list of "defines" to update.
  103531. * @param scene defines the scene the material belongs to.
  103532. */
  103533. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103534. /**
  103535. * Binds the material data.
  103536. * @param uniformBuffer defines the Uniform buffer to fill in.
  103537. * @param scene defines the scene the material belongs to.
  103538. * @param isFrozen defines wether the material is frozen or not.
  103539. */
  103540. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103541. /**
  103542. * Checks to see if a texture is used in the material.
  103543. * @param texture - Base texture to use.
  103544. * @returns - Boolean specifying if a texture is used in the material.
  103545. */
  103546. hasTexture(texture: BaseTexture): boolean;
  103547. /**
  103548. * Returns an array of the actively used textures.
  103549. * @param activeTextures Array of BaseTextures
  103550. */
  103551. getActiveTextures(activeTextures: BaseTexture[]): void;
  103552. /**
  103553. * Returns the animatable textures.
  103554. * @param animatables Array of animatable textures.
  103555. */
  103556. getAnimatables(animatables: IAnimatable[]): void;
  103557. /**
  103558. * Disposes the resources of the material.
  103559. * @param forceDisposeTextures - Forces the disposal of all textures.
  103560. */
  103561. dispose(forceDisposeTextures?: boolean): void;
  103562. /**
  103563. * Get the current class name of the texture useful for serialization or dynamic coding.
  103564. * @returns "PBRSheenConfiguration"
  103565. */
  103566. getClassName(): string;
  103567. /**
  103568. * Add fallbacks to the effect fallbacks list.
  103569. * @param defines defines the Base texture to use.
  103570. * @param fallbacks defines the current fallback list.
  103571. * @param currentRank defines the current fallback rank.
  103572. * @returns the new fallback rank.
  103573. */
  103574. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103575. /**
  103576. * Add the required uniforms to the current list.
  103577. * @param uniforms defines the current uniform list.
  103578. */
  103579. static AddUniforms(uniforms: string[]): void;
  103580. /**
  103581. * Add the required uniforms to the current buffer.
  103582. * @param uniformBuffer defines the current uniform buffer.
  103583. */
  103584. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103585. /**
  103586. * Add the required samplers to the current list.
  103587. * @param samplers defines the current sampler list.
  103588. */
  103589. static AddSamplers(samplers: string[]): void;
  103590. /**
  103591. * Makes a duplicate of the current configuration into another one.
  103592. * @param sheenConfiguration define the config where to copy the info
  103593. */
  103594. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103595. /**
  103596. * Serializes this BRDF configuration.
  103597. * @returns - An object with the serialized config.
  103598. */
  103599. serialize(): any;
  103600. /**
  103601. * Parses a Sheen Configuration from a serialized object.
  103602. * @param source - Serialized object.
  103603. */
  103604. parse(source: any): void;
  103605. }
  103606. }
  103607. declare module BABYLON {
  103608. /**
  103609. * @hidden
  103610. */
  103611. export interface IMaterialSubSurfaceDefines {
  103612. SUBSURFACE: boolean;
  103613. SS_REFRACTION: boolean;
  103614. SS_TRANSLUCENCY: boolean;
  103615. SS_SCATERRING: boolean;
  103616. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103617. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103618. SS_REFRACTIONMAP_3D: boolean;
  103619. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103620. SS_LODINREFRACTIONALPHA: boolean;
  103621. SS_GAMMAREFRACTION: boolean;
  103622. SS_RGBDREFRACTION: boolean;
  103623. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103624. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103625. /** @hidden */
  103626. _areTexturesDirty: boolean;
  103627. }
  103628. /**
  103629. * Define the code related to the sub surface parameters of the pbr material.
  103630. */
  103631. export class PBRSubSurfaceConfiguration {
  103632. private _isRefractionEnabled;
  103633. /**
  103634. * Defines if the refraction is enabled in the material.
  103635. */
  103636. isRefractionEnabled: boolean;
  103637. private _isTranslucencyEnabled;
  103638. /**
  103639. * Defines if the translucency is enabled in the material.
  103640. */
  103641. isTranslucencyEnabled: boolean;
  103642. private _isScatteringEnabled;
  103643. /**
  103644. * Defines the refraction intensity of the material.
  103645. * The refraction when enabled replaces the Diffuse part of the material.
  103646. * The intensity helps transitionning between diffuse and refraction.
  103647. */
  103648. refractionIntensity: number;
  103649. /**
  103650. * Defines the translucency intensity of the material.
  103651. * When translucency has been enabled, this defines how much of the "translucency"
  103652. * is addded to the diffuse part of the material.
  103653. */
  103654. translucencyIntensity: number;
  103655. /**
  103656. * Defines the scattering intensity of the material.
  103657. * When scattering has been enabled, this defines how much of the "scattered light"
  103658. * is addded to the diffuse part of the material.
  103659. */
  103660. scatteringIntensity: number;
  103661. private _thicknessTexture;
  103662. /**
  103663. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103664. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103665. * 0 would mean minimumThickness
  103666. * 1 would mean maximumThickness
  103667. * The other channels might be use as a mask to vary the different effects intensity.
  103668. */
  103669. thicknessTexture: Nullable<BaseTexture>;
  103670. private _refractionTexture;
  103671. /**
  103672. * Defines the texture to use for refraction.
  103673. */
  103674. refractionTexture: Nullable<BaseTexture>;
  103675. private _indexOfRefraction;
  103676. /**
  103677. * Defines the indice of refraction used in the material.
  103678. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103679. */
  103680. indexOfRefraction: number;
  103681. private _invertRefractionY;
  103682. /**
  103683. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103684. */
  103685. invertRefractionY: boolean;
  103686. private _linkRefractionWithTransparency;
  103687. /**
  103688. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103689. * Materials half opaque for instance using refraction could benefit from this control.
  103690. */
  103691. linkRefractionWithTransparency: boolean;
  103692. /**
  103693. * Defines the minimum thickness stored in the thickness map.
  103694. * If no thickness map is defined, this value will be used to simulate thickness.
  103695. */
  103696. minimumThickness: number;
  103697. /**
  103698. * Defines the maximum thickness stored in the thickness map.
  103699. */
  103700. maximumThickness: number;
  103701. /**
  103702. * Defines the volume tint of the material.
  103703. * This is used for both translucency and scattering.
  103704. */
  103705. tintColor: Color3;
  103706. /**
  103707. * Defines the distance at which the tint color should be found in the media.
  103708. * This is used for refraction only.
  103709. */
  103710. tintColorAtDistance: number;
  103711. /**
  103712. * Defines how far each channel transmit through the media.
  103713. * It is defined as a color to simplify it selection.
  103714. */
  103715. diffusionDistance: Color3;
  103716. private _useMaskFromThicknessTexture;
  103717. /**
  103718. * Stores the intensity of the different subsurface effects in the thickness texture.
  103719. * * the green channel is the translucency intensity.
  103720. * * the blue channel is the scattering intensity.
  103721. * * the alpha channel is the refraction intensity.
  103722. */
  103723. useMaskFromThicknessTexture: boolean;
  103724. /** @hidden */
  103725. private _internalMarkAllSubMeshesAsTexturesDirty;
  103726. /** @hidden */
  103727. _markAllSubMeshesAsTexturesDirty(): void;
  103728. /**
  103729. * Instantiate a new istance of sub surface configuration.
  103730. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103731. */
  103732. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103733. /**
  103734. * Gets wehter the submesh is ready to be used or not.
  103735. * @param defines the list of "defines" to update.
  103736. * @param scene defines the scene the material belongs to.
  103737. * @returns - boolean indicating that the submesh is ready or not.
  103738. */
  103739. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103740. /**
  103741. * Checks to see if a texture is used in the material.
  103742. * @param defines the list of "defines" to update.
  103743. * @param scene defines the scene to the material belongs to.
  103744. */
  103745. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103746. /**
  103747. * Binds the material data.
  103748. * @param uniformBuffer defines the Uniform buffer to fill in.
  103749. * @param scene defines the scene the material belongs to.
  103750. * @param engine defines the engine the material belongs to.
  103751. * @param isFrozen defines wether the material is frozen or not.
  103752. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103753. */
  103754. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103755. /**
  103756. * Unbinds the material from the mesh.
  103757. * @param activeEffect defines the effect that should be unbound from.
  103758. * @returns true if unbound, otherwise false
  103759. */
  103760. unbind(activeEffect: Effect): boolean;
  103761. /**
  103762. * Returns the texture used for refraction or null if none is used.
  103763. * @param scene defines the scene the material belongs to.
  103764. * @returns - Refraction texture if present. If no refraction texture and refraction
  103765. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103766. */
  103767. private _getRefractionTexture;
  103768. /**
  103769. * Returns true if alpha blending should be disabled.
  103770. */
  103771. readonly disableAlphaBlending: boolean;
  103772. /**
  103773. * Fills the list of render target textures.
  103774. * @param renderTargets the list of render targets to update
  103775. */
  103776. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103777. /**
  103778. * Checks to see if a texture is used in the material.
  103779. * @param texture - Base texture to use.
  103780. * @returns - Boolean specifying if a texture is used in the material.
  103781. */
  103782. hasTexture(texture: BaseTexture): boolean;
  103783. /**
  103784. * Gets a boolean indicating that current material needs to register RTT
  103785. * @returns true if this uses a render target otherwise false.
  103786. */
  103787. hasRenderTargetTextures(): boolean;
  103788. /**
  103789. * Returns an array of the actively used textures.
  103790. * @param activeTextures Array of BaseTextures
  103791. */
  103792. getActiveTextures(activeTextures: BaseTexture[]): void;
  103793. /**
  103794. * Returns the animatable textures.
  103795. * @param animatables Array of animatable textures.
  103796. */
  103797. getAnimatables(animatables: IAnimatable[]): void;
  103798. /**
  103799. * Disposes the resources of the material.
  103800. * @param forceDisposeTextures - Forces the disposal of all textures.
  103801. */
  103802. dispose(forceDisposeTextures?: boolean): void;
  103803. /**
  103804. * Get the current class name of the texture useful for serialization or dynamic coding.
  103805. * @returns "PBRSubSurfaceConfiguration"
  103806. */
  103807. getClassName(): string;
  103808. /**
  103809. * Add fallbacks to the effect fallbacks list.
  103810. * @param defines defines the Base texture to use.
  103811. * @param fallbacks defines the current fallback list.
  103812. * @param currentRank defines the current fallback rank.
  103813. * @returns the new fallback rank.
  103814. */
  103815. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103816. /**
  103817. * Add the required uniforms to the current list.
  103818. * @param uniforms defines the current uniform list.
  103819. */
  103820. static AddUniforms(uniforms: string[]): void;
  103821. /**
  103822. * Add the required samplers to the current list.
  103823. * @param samplers defines the current sampler list.
  103824. */
  103825. static AddSamplers(samplers: string[]): void;
  103826. /**
  103827. * Add the required uniforms to the current buffer.
  103828. * @param uniformBuffer defines the current uniform buffer.
  103829. */
  103830. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103831. /**
  103832. * Makes a duplicate of the current configuration into another one.
  103833. * @param configuration define the config where to copy the info
  103834. */
  103835. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  103836. /**
  103837. * Serializes this Sub Surface configuration.
  103838. * @returns - An object with the serialized config.
  103839. */
  103840. serialize(): any;
  103841. /**
  103842. * Parses a Sub Surface Configuration from a serialized object.
  103843. * @param source - Serialized object.
  103844. */
  103845. parse(source: any): void;
  103846. }
  103847. }
  103848. declare module BABYLON {
  103849. /** @hidden */
  103850. export var pbrFragmentDeclaration: {
  103851. name: string;
  103852. shader: string;
  103853. };
  103854. }
  103855. declare module BABYLON {
  103856. /** @hidden */
  103857. export var pbrUboDeclaration: {
  103858. name: string;
  103859. shader: string;
  103860. };
  103861. }
  103862. declare module BABYLON {
  103863. /** @hidden */
  103864. export var pbrFragmentExtraDeclaration: {
  103865. name: string;
  103866. shader: string;
  103867. };
  103868. }
  103869. declare module BABYLON {
  103870. /** @hidden */
  103871. export var pbrFragmentSamplersDeclaration: {
  103872. name: string;
  103873. shader: string;
  103874. };
  103875. }
  103876. declare module BABYLON {
  103877. /** @hidden */
  103878. export var pbrHelperFunctions: {
  103879. name: string;
  103880. shader: string;
  103881. };
  103882. }
  103883. declare module BABYLON {
  103884. /** @hidden */
  103885. export var harmonicsFunctions: {
  103886. name: string;
  103887. shader: string;
  103888. };
  103889. }
  103890. declare module BABYLON {
  103891. /** @hidden */
  103892. export var pbrDirectLightingSetupFunctions: {
  103893. name: string;
  103894. shader: string;
  103895. };
  103896. }
  103897. declare module BABYLON {
  103898. /** @hidden */
  103899. export var pbrDirectLightingFalloffFunctions: {
  103900. name: string;
  103901. shader: string;
  103902. };
  103903. }
  103904. declare module BABYLON {
  103905. /** @hidden */
  103906. export var pbrBRDFFunctions: {
  103907. name: string;
  103908. shader: string;
  103909. };
  103910. }
  103911. declare module BABYLON {
  103912. /** @hidden */
  103913. export var pbrDirectLightingFunctions: {
  103914. name: string;
  103915. shader: string;
  103916. };
  103917. }
  103918. declare module BABYLON {
  103919. /** @hidden */
  103920. export var pbrIBLFunctions: {
  103921. name: string;
  103922. shader: string;
  103923. };
  103924. }
  103925. declare module BABYLON {
  103926. /** @hidden */
  103927. export var pbrDebug: {
  103928. name: string;
  103929. shader: string;
  103930. };
  103931. }
  103932. declare module BABYLON {
  103933. /** @hidden */
  103934. export var pbrPixelShader: {
  103935. name: string;
  103936. shader: string;
  103937. };
  103938. }
  103939. declare module BABYLON {
  103940. /** @hidden */
  103941. export var pbrVertexDeclaration: {
  103942. name: string;
  103943. shader: string;
  103944. };
  103945. }
  103946. declare module BABYLON {
  103947. /** @hidden */
  103948. export var pbrVertexShader: {
  103949. name: string;
  103950. shader: string;
  103951. };
  103952. }
  103953. declare module BABYLON {
  103954. /**
  103955. * Manages the defines for the PBR Material.
  103956. * @hidden
  103957. */
  103958. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  103959. PBR: boolean;
  103960. MAINUV1: boolean;
  103961. MAINUV2: boolean;
  103962. UV1: boolean;
  103963. UV2: boolean;
  103964. ALBEDO: boolean;
  103965. ALBEDODIRECTUV: number;
  103966. VERTEXCOLOR: boolean;
  103967. AMBIENT: boolean;
  103968. AMBIENTDIRECTUV: number;
  103969. AMBIENTINGRAYSCALE: boolean;
  103970. OPACITY: boolean;
  103971. VERTEXALPHA: boolean;
  103972. OPACITYDIRECTUV: number;
  103973. OPACITYRGB: boolean;
  103974. ALPHATEST: boolean;
  103975. DEPTHPREPASS: boolean;
  103976. ALPHABLEND: boolean;
  103977. ALPHAFROMALBEDO: boolean;
  103978. ALPHATESTVALUE: string;
  103979. SPECULAROVERALPHA: boolean;
  103980. RADIANCEOVERALPHA: boolean;
  103981. ALPHAFRESNEL: boolean;
  103982. LINEARALPHAFRESNEL: boolean;
  103983. PREMULTIPLYALPHA: boolean;
  103984. EMISSIVE: boolean;
  103985. EMISSIVEDIRECTUV: number;
  103986. REFLECTIVITY: boolean;
  103987. REFLECTIVITYDIRECTUV: number;
  103988. SPECULARTERM: boolean;
  103989. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  103990. MICROSURFACEAUTOMATIC: boolean;
  103991. LODBASEDMICROSFURACE: boolean;
  103992. MICROSURFACEMAP: boolean;
  103993. MICROSURFACEMAPDIRECTUV: number;
  103994. METALLICWORKFLOW: boolean;
  103995. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  103996. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  103997. METALLNESSSTOREINMETALMAPBLUE: boolean;
  103998. AOSTOREINMETALMAPRED: boolean;
  103999. ENVIRONMENTBRDF: boolean;
  104000. ENVIRONMENTBRDF_RGBD: boolean;
  104001. NORMAL: boolean;
  104002. TANGENT: boolean;
  104003. BUMP: boolean;
  104004. BUMPDIRECTUV: number;
  104005. OBJECTSPACE_NORMALMAP: boolean;
  104006. PARALLAX: boolean;
  104007. PARALLAXOCCLUSION: boolean;
  104008. NORMALXYSCALE: boolean;
  104009. LIGHTMAP: boolean;
  104010. LIGHTMAPDIRECTUV: number;
  104011. USELIGHTMAPASSHADOWMAP: boolean;
  104012. GAMMALIGHTMAP: boolean;
  104013. REFLECTION: boolean;
  104014. REFLECTIONMAP_3D: boolean;
  104015. REFLECTIONMAP_SPHERICAL: boolean;
  104016. REFLECTIONMAP_PLANAR: boolean;
  104017. REFLECTIONMAP_CUBIC: boolean;
  104018. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104019. REFLECTIONMAP_PROJECTION: boolean;
  104020. REFLECTIONMAP_SKYBOX: boolean;
  104021. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104022. REFLECTIONMAP_EXPLICIT: boolean;
  104023. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104024. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104025. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104026. INVERTCUBICMAP: boolean;
  104027. USESPHERICALFROMREFLECTIONMAP: boolean;
  104028. USESPHERICALINVERTEX: boolean;
  104029. REFLECTIONMAP_OPPOSITEZ: boolean;
  104030. LODINREFLECTIONALPHA: boolean;
  104031. GAMMAREFLECTION: boolean;
  104032. RGBDREFLECTION: boolean;
  104033. RADIANCEOCCLUSION: boolean;
  104034. HORIZONOCCLUSION: boolean;
  104035. INSTANCES: boolean;
  104036. NUM_BONE_INFLUENCERS: number;
  104037. BonesPerMesh: number;
  104038. BONETEXTURE: boolean;
  104039. NONUNIFORMSCALING: boolean;
  104040. MORPHTARGETS: boolean;
  104041. MORPHTARGETS_NORMAL: boolean;
  104042. MORPHTARGETS_TANGENT: boolean;
  104043. NUM_MORPH_INFLUENCERS: number;
  104044. IMAGEPROCESSING: boolean;
  104045. VIGNETTE: boolean;
  104046. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104047. VIGNETTEBLENDMODEOPAQUE: boolean;
  104048. TONEMAPPING: boolean;
  104049. TONEMAPPING_ACES: boolean;
  104050. CONTRAST: boolean;
  104051. COLORCURVES: boolean;
  104052. COLORGRADING: boolean;
  104053. COLORGRADING3D: boolean;
  104054. SAMPLER3DGREENDEPTH: boolean;
  104055. SAMPLER3DBGRMAP: boolean;
  104056. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104057. EXPOSURE: boolean;
  104058. MULTIVIEW: boolean;
  104059. USEPHYSICALLIGHTFALLOFF: boolean;
  104060. USEGLTFLIGHTFALLOFF: boolean;
  104061. TWOSIDEDLIGHTING: boolean;
  104062. SHADOWFLOAT: boolean;
  104063. CLIPPLANE: boolean;
  104064. CLIPPLANE2: boolean;
  104065. CLIPPLANE3: boolean;
  104066. CLIPPLANE4: boolean;
  104067. POINTSIZE: boolean;
  104068. FOG: boolean;
  104069. LOGARITHMICDEPTH: boolean;
  104070. FORCENORMALFORWARD: boolean;
  104071. SPECULARAA: boolean;
  104072. CLEARCOAT: boolean;
  104073. CLEARCOAT_DEFAULTIOR: boolean;
  104074. CLEARCOAT_TEXTURE: boolean;
  104075. CLEARCOAT_TEXTUREDIRECTUV: number;
  104076. CLEARCOAT_BUMP: boolean;
  104077. CLEARCOAT_BUMPDIRECTUV: number;
  104078. CLEARCOAT_TINT: boolean;
  104079. CLEARCOAT_TINT_TEXTURE: boolean;
  104080. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104081. ANISOTROPIC: boolean;
  104082. ANISOTROPIC_TEXTURE: boolean;
  104083. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104084. BRDF_V_HEIGHT_CORRELATED: boolean;
  104085. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104086. SHEEN: boolean;
  104087. SHEEN_TEXTURE: boolean;
  104088. SHEEN_TEXTUREDIRECTUV: number;
  104089. SHEEN_LINKWITHALBEDO: boolean;
  104090. SUBSURFACE: boolean;
  104091. SS_REFRACTION: boolean;
  104092. SS_TRANSLUCENCY: boolean;
  104093. SS_SCATERRING: boolean;
  104094. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104095. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104096. SS_REFRACTIONMAP_3D: boolean;
  104097. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104098. SS_LODINREFRACTIONALPHA: boolean;
  104099. SS_GAMMAREFRACTION: boolean;
  104100. SS_RGBDREFRACTION: boolean;
  104101. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104102. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104103. UNLIT: boolean;
  104104. DEBUGMODE: number;
  104105. /**
  104106. * Initializes the PBR Material defines.
  104107. */
  104108. constructor();
  104109. /**
  104110. * Resets the PBR Material defines.
  104111. */
  104112. reset(): void;
  104113. }
  104114. /**
  104115. * The Physically based material base class of BJS.
  104116. *
  104117. * This offers the main features of a standard PBR material.
  104118. * For more information, please refer to the documentation :
  104119. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104120. */
  104121. export abstract class PBRBaseMaterial extends PushMaterial {
  104122. /**
  104123. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104124. */
  104125. static readonly PBRMATERIAL_OPAQUE: number;
  104126. /**
  104127. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104128. */
  104129. static readonly PBRMATERIAL_ALPHATEST: number;
  104130. /**
  104131. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104132. */
  104133. static readonly PBRMATERIAL_ALPHABLEND: number;
  104134. /**
  104135. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104136. * They are also discarded below the alpha cutoff threshold to improve performances.
  104137. */
  104138. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104139. /**
  104140. * Defines the default value of how much AO map is occluding the analytical lights
  104141. * (point spot...).
  104142. */
  104143. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104144. /**
  104145. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104146. */
  104147. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104148. /**
  104149. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104150. * to enhance interoperability with other engines.
  104151. */
  104152. static readonly LIGHTFALLOFF_GLTF: number;
  104153. /**
  104154. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104155. * to enhance interoperability with other materials.
  104156. */
  104157. static readonly LIGHTFALLOFF_STANDARD: number;
  104158. /**
  104159. * Intensity of the direct lights e.g. the four lights available in your scene.
  104160. * This impacts both the direct diffuse and specular highlights.
  104161. */
  104162. protected _directIntensity: number;
  104163. /**
  104164. * Intensity of the emissive part of the material.
  104165. * This helps controlling the emissive effect without modifying the emissive color.
  104166. */
  104167. protected _emissiveIntensity: number;
  104168. /**
  104169. * Intensity of the environment e.g. how much the environment will light the object
  104170. * either through harmonics for rough material or through the refelction for shiny ones.
  104171. */
  104172. protected _environmentIntensity: number;
  104173. /**
  104174. * This is a special control allowing the reduction of the specular highlights coming from the
  104175. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104176. */
  104177. protected _specularIntensity: number;
  104178. /**
  104179. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104180. */
  104181. private _lightingInfos;
  104182. /**
  104183. * Debug Control allowing disabling the bump map on this material.
  104184. */
  104185. protected _disableBumpMap: boolean;
  104186. /**
  104187. * AKA Diffuse Texture in standard nomenclature.
  104188. */
  104189. protected _albedoTexture: Nullable<BaseTexture>;
  104190. /**
  104191. * AKA Occlusion Texture in other nomenclature.
  104192. */
  104193. protected _ambientTexture: Nullable<BaseTexture>;
  104194. /**
  104195. * AKA Occlusion Texture Intensity in other nomenclature.
  104196. */
  104197. protected _ambientTextureStrength: number;
  104198. /**
  104199. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104200. * 1 means it completely occludes it
  104201. * 0 mean it has no impact
  104202. */
  104203. protected _ambientTextureImpactOnAnalyticalLights: number;
  104204. /**
  104205. * Stores the alpha values in a texture.
  104206. */
  104207. protected _opacityTexture: Nullable<BaseTexture>;
  104208. /**
  104209. * Stores the reflection values in a texture.
  104210. */
  104211. protected _reflectionTexture: Nullable<BaseTexture>;
  104212. /**
  104213. * Stores the emissive values in a texture.
  104214. */
  104215. protected _emissiveTexture: Nullable<BaseTexture>;
  104216. /**
  104217. * AKA Specular texture in other nomenclature.
  104218. */
  104219. protected _reflectivityTexture: Nullable<BaseTexture>;
  104220. /**
  104221. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104222. */
  104223. protected _metallicTexture: Nullable<BaseTexture>;
  104224. /**
  104225. * Specifies the metallic scalar of the metallic/roughness workflow.
  104226. * Can also be used to scale the metalness values of the metallic texture.
  104227. */
  104228. protected _metallic: Nullable<number>;
  104229. /**
  104230. * Specifies the roughness scalar of the metallic/roughness workflow.
  104231. * Can also be used to scale the roughness values of the metallic texture.
  104232. */
  104233. protected _roughness: Nullable<number>;
  104234. /**
  104235. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104236. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104237. */
  104238. protected _microSurfaceTexture: Nullable<BaseTexture>;
  104239. /**
  104240. * Stores surface normal data used to displace a mesh in a texture.
  104241. */
  104242. protected _bumpTexture: Nullable<BaseTexture>;
  104243. /**
  104244. * Stores the pre-calculated light information of a mesh in a texture.
  104245. */
  104246. protected _lightmapTexture: Nullable<BaseTexture>;
  104247. /**
  104248. * The color of a material in ambient lighting.
  104249. */
  104250. protected _ambientColor: Color3;
  104251. /**
  104252. * AKA Diffuse Color in other nomenclature.
  104253. */
  104254. protected _albedoColor: Color3;
  104255. /**
  104256. * AKA Specular Color in other nomenclature.
  104257. */
  104258. protected _reflectivityColor: Color3;
  104259. /**
  104260. * The color applied when light is reflected from a material.
  104261. */
  104262. protected _reflectionColor: Color3;
  104263. /**
  104264. * The color applied when light is emitted from a material.
  104265. */
  104266. protected _emissiveColor: Color3;
  104267. /**
  104268. * AKA Glossiness in other nomenclature.
  104269. */
  104270. protected _microSurface: number;
  104271. /**
  104272. * Specifies that the material will use the light map as a show map.
  104273. */
  104274. protected _useLightmapAsShadowmap: boolean;
  104275. /**
  104276. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104277. * makes the reflect vector face the model (under horizon).
  104278. */
  104279. protected _useHorizonOcclusion: boolean;
  104280. /**
  104281. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104282. * too much the area relying on ambient texture to define their ambient occlusion.
  104283. */
  104284. protected _useRadianceOcclusion: boolean;
  104285. /**
  104286. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104287. */
  104288. protected _useAlphaFromAlbedoTexture: boolean;
  104289. /**
  104290. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104291. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104292. */
  104293. protected _useSpecularOverAlpha: boolean;
  104294. /**
  104295. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104296. */
  104297. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104298. /**
  104299. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104300. */
  104301. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104302. /**
  104303. * Specifies if the metallic texture contains the roughness information in its green channel.
  104304. */
  104305. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104306. /**
  104307. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104308. */
  104309. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104310. /**
  104311. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104312. */
  104313. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104314. /**
  104315. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104316. */
  104317. protected _useAmbientInGrayScale: boolean;
  104318. /**
  104319. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104320. * The material will try to infer what glossiness each pixel should be.
  104321. */
  104322. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104323. /**
  104324. * Defines the falloff type used in this material.
  104325. * It by default is Physical.
  104326. */
  104327. protected _lightFalloff: number;
  104328. /**
  104329. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104330. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104331. */
  104332. protected _useRadianceOverAlpha: boolean;
  104333. /**
  104334. * Allows using an object space normal map (instead of tangent space).
  104335. */
  104336. protected _useObjectSpaceNormalMap: boolean;
  104337. /**
  104338. * Allows using the bump map in parallax mode.
  104339. */
  104340. protected _useParallax: boolean;
  104341. /**
  104342. * Allows using the bump map in parallax occlusion mode.
  104343. */
  104344. protected _useParallaxOcclusion: boolean;
  104345. /**
  104346. * Controls the scale bias of the parallax mode.
  104347. */
  104348. protected _parallaxScaleBias: number;
  104349. /**
  104350. * If sets to true, disables all the lights affecting the material.
  104351. */
  104352. protected _disableLighting: boolean;
  104353. /**
  104354. * Number of Simultaneous lights allowed on the material.
  104355. */
  104356. protected _maxSimultaneousLights: number;
  104357. /**
  104358. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104359. */
  104360. protected _invertNormalMapX: boolean;
  104361. /**
  104362. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104363. */
  104364. protected _invertNormalMapY: boolean;
  104365. /**
  104366. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104367. */
  104368. protected _twoSidedLighting: boolean;
  104369. /**
  104370. * Defines the alpha limits in alpha test mode.
  104371. */
  104372. protected _alphaCutOff: number;
  104373. /**
  104374. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104375. */
  104376. protected _forceAlphaTest: boolean;
  104377. /**
  104378. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104379. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104380. */
  104381. protected _useAlphaFresnel: boolean;
  104382. /**
  104383. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104384. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104385. */
  104386. protected _useLinearAlphaFresnel: boolean;
  104387. /**
  104388. * The transparency mode of the material.
  104389. */
  104390. protected _transparencyMode: Nullable<number>;
  104391. /**
  104392. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104393. * from cos thetav and roughness:
  104394. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104395. */
  104396. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104397. /**
  104398. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104399. */
  104400. protected _forceIrradianceInFragment: boolean;
  104401. /**
  104402. * Force normal to face away from face.
  104403. */
  104404. protected _forceNormalForward: boolean;
  104405. /**
  104406. * Enables specular anti aliasing in the PBR shader.
  104407. * It will both interacts on the Geometry for analytical and IBL lighting.
  104408. * It also prefilter the roughness map based on the bump values.
  104409. */
  104410. protected _enableSpecularAntiAliasing: boolean;
  104411. /**
  104412. * Default configuration related to image processing available in the PBR Material.
  104413. */
  104414. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104415. /**
  104416. * Keep track of the image processing observer to allow dispose and replace.
  104417. */
  104418. private _imageProcessingObserver;
  104419. /**
  104420. * Attaches a new image processing configuration to the PBR Material.
  104421. * @param configuration
  104422. */
  104423. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104424. /**
  104425. * Stores the available render targets.
  104426. */
  104427. private _renderTargets;
  104428. /**
  104429. * Sets the global ambient color for the material used in lighting calculations.
  104430. */
  104431. private _globalAmbientColor;
  104432. /**
  104433. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104434. */
  104435. private _useLogarithmicDepth;
  104436. /**
  104437. * If set to true, no lighting calculations will be applied.
  104438. */
  104439. private _unlit;
  104440. private _debugMode;
  104441. /**
  104442. * @hidden
  104443. * This is reserved for the inspector.
  104444. * Defines the material debug mode.
  104445. * It helps seeing only some components of the material while troubleshooting.
  104446. */
  104447. debugMode: number;
  104448. /**
  104449. * @hidden
  104450. * This is reserved for the inspector.
  104451. * Specify from where on screen the debug mode should start.
  104452. * The value goes from -1 (full screen) to 1 (not visible)
  104453. * It helps with side by side comparison against the final render
  104454. * This defaults to -1
  104455. */
  104456. private debugLimit;
  104457. /**
  104458. * @hidden
  104459. * This is reserved for the inspector.
  104460. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104461. * You can use the factor to better multiply the final value.
  104462. */
  104463. private debugFactor;
  104464. /**
  104465. * Defines the clear coat layer parameters for the material.
  104466. */
  104467. readonly clearCoat: PBRClearCoatConfiguration;
  104468. /**
  104469. * Defines the anisotropic parameters for the material.
  104470. */
  104471. readonly anisotropy: PBRAnisotropicConfiguration;
  104472. /**
  104473. * Defines the BRDF parameters for the material.
  104474. */
  104475. readonly brdf: PBRBRDFConfiguration;
  104476. /**
  104477. * Defines the Sheen parameters for the material.
  104478. */
  104479. readonly sheen: PBRSheenConfiguration;
  104480. /**
  104481. * Defines the SubSurface parameters for the material.
  104482. */
  104483. readonly subSurface: PBRSubSurfaceConfiguration;
  104484. /**
  104485. * Custom callback helping to override the default shader used in the material.
  104486. */
  104487. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104488. /**
  104489. * Instantiates a new PBRMaterial instance.
  104490. *
  104491. * @param name The material name
  104492. * @param scene The scene the material will be use in.
  104493. */
  104494. constructor(name: string, scene: Scene);
  104495. /**
  104496. * Gets a boolean indicating that current material needs to register RTT
  104497. */
  104498. readonly hasRenderTargetTextures: boolean;
  104499. /**
  104500. * Gets the name of the material class.
  104501. */
  104502. getClassName(): string;
  104503. /**
  104504. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104505. */
  104506. /**
  104507. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104508. */
  104509. useLogarithmicDepth: boolean;
  104510. /**
  104511. * Gets the current transparency mode.
  104512. */
  104513. /**
  104514. * Sets the transparency mode of the material.
  104515. *
  104516. * | Value | Type | Description |
  104517. * | ----- | ----------------------------------- | ----------- |
  104518. * | 0 | OPAQUE | |
  104519. * | 1 | ALPHATEST | |
  104520. * | 2 | ALPHABLEND | |
  104521. * | 3 | ALPHATESTANDBLEND | |
  104522. *
  104523. */
  104524. transparencyMode: Nullable<number>;
  104525. /**
  104526. * Returns true if alpha blending should be disabled.
  104527. */
  104528. private readonly _disableAlphaBlending;
  104529. /**
  104530. * Specifies whether or not this material should be rendered in alpha blend mode.
  104531. */
  104532. needAlphaBlending(): boolean;
  104533. /**
  104534. * Specifies if the mesh will require alpha blending.
  104535. * @param mesh - BJS mesh.
  104536. */
  104537. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104538. /**
  104539. * Specifies whether or not this material should be rendered in alpha test mode.
  104540. */
  104541. needAlphaTesting(): boolean;
  104542. /**
  104543. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104544. */
  104545. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104546. /**
  104547. * Gets the texture used for the alpha test.
  104548. */
  104549. getAlphaTestTexture(): Nullable<BaseTexture>;
  104550. /**
  104551. * Specifies that the submesh is ready to be used.
  104552. * @param mesh - BJS mesh.
  104553. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104554. * @param useInstances - Specifies that instances should be used.
  104555. * @returns - boolean indicating that the submesh is ready or not.
  104556. */
  104557. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104558. /**
  104559. * Specifies if the material uses metallic roughness workflow.
  104560. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104561. */
  104562. isMetallicWorkflow(): boolean;
  104563. private _prepareEffect;
  104564. private _prepareDefines;
  104565. /**
  104566. * Force shader compilation
  104567. */
  104568. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104569. clipPlane: boolean;
  104570. }>): void;
  104571. /**
  104572. * Initializes the uniform buffer layout for the shader.
  104573. */
  104574. buildUniformLayout(): void;
  104575. /**
  104576. * Unbinds the material from the mesh
  104577. */
  104578. unbind(): void;
  104579. /**
  104580. * Binds the submesh data.
  104581. * @param world - The world matrix.
  104582. * @param mesh - The BJS mesh.
  104583. * @param subMesh - A submesh of the BJS mesh.
  104584. */
  104585. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104586. /**
  104587. * Returns the animatable textures.
  104588. * @returns - Array of animatable textures.
  104589. */
  104590. getAnimatables(): IAnimatable[];
  104591. /**
  104592. * Returns the texture used for reflections.
  104593. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104594. */
  104595. private _getReflectionTexture;
  104596. /**
  104597. * Returns an array of the actively used textures.
  104598. * @returns - Array of BaseTextures
  104599. */
  104600. getActiveTextures(): BaseTexture[];
  104601. /**
  104602. * Checks to see if a texture is used in the material.
  104603. * @param texture - Base texture to use.
  104604. * @returns - Boolean specifying if a texture is used in the material.
  104605. */
  104606. hasTexture(texture: BaseTexture): boolean;
  104607. /**
  104608. * Disposes the resources of the material.
  104609. * @param forceDisposeEffect - Forces the disposal of effects.
  104610. * @param forceDisposeTextures - Forces the disposal of all textures.
  104611. */
  104612. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104613. }
  104614. }
  104615. declare module BABYLON {
  104616. /**
  104617. * The Physically based material of BJS.
  104618. *
  104619. * This offers the main features of a standard PBR material.
  104620. * For more information, please refer to the documentation :
  104621. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104622. */
  104623. export class PBRMaterial extends PBRBaseMaterial {
  104624. /**
  104625. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104626. */
  104627. static readonly PBRMATERIAL_OPAQUE: number;
  104628. /**
  104629. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104630. */
  104631. static readonly PBRMATERIAL_ALPHATEST: number;
  104632. /**
  104633. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104634. */
  104635. static readonly PBRMATERIAL_ALPHABLEND: number;
  104636. /**
  104637. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104638. * They are also discarded below the alpha cutoff threshold to improve performances.
  104639. */
  104640. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104641. /**
  104642. * Defines the default value of how much AO map is occluding the analytical lights
  104643. * (point spot...).
  104644. */
  104645. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104646. /**
  104647. * Intensity of the direct lights e.g. the four lights available in your scene.
  104648. * This impacts both the direct diffuse and specular highlights.
  104649. */
  104650. directIntensity: number;
  104651. /**
  104652. * Intensity of the emissive part of the material.
  104653. * This helps controlling the emissive effect without modifying the emissive color.
  104654. */
  104655. emissiveIntensity: number;
  104656. /**
  104657. * Intensity of the environment e.g. how much the environment will light the object
  104658. * either through harmonics for rough material or through the refelction for shiny ones.
  104659. */
  104660. environmentIntensity: number;
  104661. /**
  104662. * This is a special control allowing the reduction of the specular highlights coming from the
  104663. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104664. */
  104665. specularIntensity: number;
  104666. /**
  104667. * Debug Control allowing disabling the bump map on this material.
  104668. */
  104669. disableBumpMap: boolean;
  104670. /**
  104671. * AKA Diffuse Texture in standard nomenclature.
  104672. */
  104673. albedoTexture: BaseTexture;
  104674. /**
  104675. * AKA Occlusion Texture in other nomenclature.
  104676. */
  104677. ambientTexture: BaseTexture;
  104678. /**
  104679. * AKA Occlusion Texture Intensity in other nomenclature.
  104680. */
  104681. ambientTextureStrength: number;
  104682. /**
  104683. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104684. * 1 means it completely occludes it
  104685. * 0 mean it has no impact
  104686. */
  104687. ambientTextureImpactOnAnalyticalLights: number;
  104688. /**
  104689. * Stores the alpha values in a texture.
  104690. */
  104691. opacityTexture: BaseTexture;
  104692. /**
  104693. * Stores the reflection values in a texture.
  104694. */
  104695. reflectionTexture: Nullable<BaseTexture>;
  104696. /**
  104697. * Stores the emissive values in a texture.
  104698. */
  104699. emissiveTexture: BaseTexture;
  104700. /**
  104701. * AKA Specular texture in other nomenclature.
  104702. */
  104703. reflectivityTexture: BaseTexture;
  104704. /**
  104705. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104706. */
  104707. metallicTexture: BaseTexture;
  104708. /**
  104709. * Specifies the metallic scalar of the metallic/roughness workflow.
  104710. * Can also be used to scale the metalness values of the metallic texture.
  104711. */
  104712. metallic: Nullable<number>;
  104713. /**
  104714. * Specifies the roughness scalar of the metallic/roughness workflow.
  104715. * Can also be used to scale the roughness values of the metallic texture.
  104716. */
  104717. roughness: Nullable<number>;
  104718. /**
  104719. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104720. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104721. */
  104722. microSurfaceTexture: BaseTexture;
  104723. /**
  104724. * Stores surface normal data used to displace a mesh in a texture.
  104725. */
  104726. bumpTexture: BaseTexture;
  104727. /**
  104728. * Stores the pre-calculated light information of a mesh in a texture.
  104729. */
  104730. lightmapTexture: BaseTexture;
  104731. /**
  104732. * Stores the refracted light information in a texture.
  104733. */
  104734. refractionTexture: Nullable<BaseTexture>;
  104735. /**
  104736. * The color of a material in ambient lighting.
  104737. */
  104738. ambientColor: Color3;
  104739. /**
  104740. * AKA Diffuse Color in other nomenclature.
  104741. */
  104742. albedoColor: Color3;
  104743. /**
  104744. * AKA Specular Color in other nomenclature.
  104745. */
  104746. reflectivityColor: Color3;
  104747. /**
  104748. * The color reflected from the material.
  104749. */
  104750. reflectionColor: Color3;
  104751. /**
  104752. * The color emitted from the material.
  104753. */
  104754. emissiveColor: Color3;
  104755. /**
  104756. * AKA Glossiness in other nomenclature.
  104757. */
  104758. microSurface: number;
  104759. /**
  104760. * source material index of refraction (IOR)' / 'destination material IOR.
  104761. */
  104762. indexOfRefraction: number;
  104763. /**
  104764. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104765. */
  104766. invertRefractionY: boolean;
  104767. /**
  104768. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104769. * Materials half opaque for instance using refraction could benefit from this control.
  104770. */
  104771. linkRefractionWithTransparency: boolean;
  104772. /**
  104773. * If true, the light map contains occlusion information instead of lighting info.
  104774. */
  104775. useLightmapAsShadowmap: boolean;
  104776. /**
  104777. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104778. */
  104779. useAlphaFromAlbedoTexture: boolean;
  104780. /**
  104781. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104782. */
  104783. forceAlphaTest: boolean;
  104784. /**
  104785. * Defines the alpha limits in alpha test mode.
  104786. */
  104787. alphaCutOff: number;
  104788. /**
  104789. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104790. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104791. */
  104792. useSpecularOverAlpha: boolean;
  104793. /**
  104794. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104795. */
  104796. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104797. /**
  104798. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104799. */
  104800. useRoughnessFromMetallicTextureAlpha: boolean;
  104801. /**
  104802. * Specifies if the metallic texture contains the roughness information in its green channel.
  104803. */
  104804. useRoughnessFromMetallicTextureGreen: boolean;
  104805. /**
  104806. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104807. */
  104808. useMetallnessFromMetallicTextureBlue: boolean;
  104809. /**
  104810. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104811. */
  104812. useAmbientOcclusionFromMetallicTextureRed: boolean;
  104813. /**
  104814. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104815. */
  104816. useAmbientInGrayScale: boolean;
  104817. /**
  104818. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104819. * The material will try to infer what glossiness each pixel should be.
  104820. */
  104821. useAutoMicroSurfaceFromReflectivityMap: boolean;
  104822. /**
  104823. * BJS is using an harcoded light falloff based on a manually sets up range.
  104824. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104825. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104826. */
  104827. /**
  104828. * BJS is using an harcoded light falloff based on a manually sets up range.
  104829. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  104830. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  104831. */
  104832. usePhysicalLightFalloff: boolean;
  104833. /**
  104834. * In order to support the falloff compatibility with gltf, a special mode has been added
  104835. * to reproduce the gltf light falloff.
  104836. */
  104837. /**
  104838. * In order to support the falloff compatibility with gltf, a special mode has been added
  104839. * to reproduce the gltf light falloff.
  104840. */
  104841. useGLTFLightFalloff: boolean;
  104842. /**
  104843. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104844. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104845. */
  104846. useRadianceOverAlpha: boolean;
  104847. /**
  104848. * Allows using an object space normal map (instead of tangent space).
  104849. */
  104850. useObjectSpaceNormalMap: boolean;
  104851. /**
  104852. * Allows using the bump map in parallax mode.
  104853. */
  104854. useParallax: boolean;
  104855. /**
  104856. * Allows using the bump map in parallax occlusion mode.
  104857. */
  104858. useParallaxOcclusion: boolean;
  104859. /**
  104860. * Controls the scale bias of the parallax mode.
  104861. */
  104862. parallaxScaleBias: number;
  104863. /**
  104864. * If sets to true, disables all the lights affecting the material.
  104865. */
  104866. disableLighting: boolean;
  104867. /**
  104868. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104869. */
  104870. forceIrradianceInFragment: boolean;
  104871. /**
  104872. * Number of Simultaneous lights allowed on the material.
  104873. */
  104874. maxSimultaneousLights: number;
  104875. /**
  104876. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  104877. */
  104878. invertNormalMapX: boolean;
  104879. /**
  104880. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  104881. */
  104882. invertNormalMapY: boolean;
  104883. /**
  104884. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104885. */
  104886. twoSidedLighting: boolean;
  104887. /**
  104888. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104889. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104890. */
  104891. useAlphaFresnel: boolean;
  104892. /**
  104893. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104894. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104895. */
  104896. useLinearAlphaFresnel: boolean;
  104897. /**
  104898. * Let user defines the brdf lookup texture used for IBL.
  104899. * A default 8bit version is embedded but you could point at :
  104900. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  104901. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  104902. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  104903. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  104904. */
  104905. environmentBRDFTexture: Nullable<BaseTexture>;
  104906. /**
  104907. * Force normal to face away from face.
  104908. */
  104909. forceNormalForward: boolean;
  104910. /**
  104911. * Enables specular anti aliasing in the PBR shader.
  104912. * It will both interacts on the Geometry for analytical and IBL lighting.
  104913. * It also prefilter the roughness map based on the bump values.
  104914. */
  104915. enableSpecularAntiAliasing: boolean;
  104916. /**
  104917. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104918. * makes the reflect vector face the model (under horizon).
  104919. */
  104920. useHorizonOcclusion: boolean;
  104921. /**
  104922. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104923. * too much the area relying on ambient texture to define their ambient occlusion.
  104924. */
  104925. useRadianceOcclusion: boolean;
  104926. /**
  104927. * If set to true, no lighting calculations will be applied.
  104928. */
  104929. unlit: boolean;
  104930. /**
  104931. * Gets the image processing configuration used either in this material.
  104932. */
  104933. /**
  104934. * Sets the Default image processing configuration used either in the this material.
  104935. *
  104936. * If sets to null, the scene one is in use.
  104937. */
  104938. imageProcessingConfiguration: ImageProcessingConfiguration;
  104939. /**
  104940. * Gets wether the color curves effect is enabled.
  104941. */
  104942. /**
  104943. * Sets wether the color curves effect is enabled.
  104944. */
  104945. cameraColorCurvesEnabled: boolean;
  104946. /**
  104947. * Gets wether the color grading effect is enabled.
  104948. */
  104949. /**
  104950. * Gets wether the color grading effect is enabled.
  104951. */
  104952. cameraColorGradingEnabled: boolean;
  104953. /**
  104954. * Gets wether tonemapping is enabled or not.
  104955. */
  104956. /**
  104957. * Sets wether tonemapping is enabled or not
  104958. */
  104959. cameraToneMappingEnabled: boolean;
  104960. /**
  104961. * The camera exposure used on this material.
  104962. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104963. * This corresponds to a photographic exposure.
  104964. */
  104965. /**
  104966. * The camera exposure used on this material.
  104967. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  104968. * This corresponds to a photographic exposure.
  104969. */
  104970. cameraExposure: number;
  104971. /**
  104972. * Gets The camera contrast used on this material.
  104973. */
  104974. /**
  104975. * Sets The camera contrast used on this material.
  104976. */
  104977. cameraContrast: number;
  104978. /**
  104979. * Gets the Color Grading 2D Lookup Texture.
  104980. */
  104981. /**
  104982. * Sets the Color Grading 2D Lookup Texture.
  104983. */
  104984. cameraColorGradingTexture: Nullable<BaseTexture>;
  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. /**
  104992. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  104993. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  104994. * 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;
  104995. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  104996. */
  104997. cameraColorCurves: Nullable<ColorCurves>;
  104998. /**
  104999. * Instantiates a new PBRMaterial instance.
  105000. *
  105001. * @param name The material name
  105002. * @param scene The scene the material will be use in.
  105003. */
  105004. constructor(name: string, scene: Scene);
  105005. /**
  105006. * Returns the name of this material class.
  105007. */
  105008. getClassName(): string;
  105009. /**
  105010. * Makes a duplicate of the current material.
  105011. * @param name - name to use for the new material.
  105012. */
  105013. clone(name: string): PBRMaterial;
  105014. /**
  105015. * Serializes this PBR Material.
  105016. * @returns - An object with the serialized material.
  105017. */
  105018. serialize(): any;
  105019. /**
  105020. * Parses a PBR Material from a serialized object.
  105021. * @param source - Serialized object.
  105022. * @param scene - BJS scene instance.
  105023. * @param rootUrl - url for the scene object
  105024. * @returns - PBRMaterial
  105025. */
  105026. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105027. }
  105028. }
  105029. declare module BABYLON {
  105030. /**
  105031. * Direct draw surface info
  105032. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105033. */
  105034. export interface DDSInfo {
  105035. /**
  105036. * Width of the texture
  105037. */
  105038. width: number;
  105039. /**
  105040. * Width of the texture
  105041. */
  105042. height: number;
  105043. /**
  105044. * Number of Mipmaps for the texture
  105045. * @see https://en.wikipedia.org/wiki/Mipmap
  105046. */
  105047. mipmapCount: number;
  105048. /**
  105049. * If the textures format is a known fourCC format
  105050. * @see https://www.fourcc.org/
  105051. */
  105052. isFourCC: boolean;
  105053. /**
  105054. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105055. */
  105056. isRGB: boolean;
  105057. /**
  105058. * If the texture is a lumincance format
  105059. */
  105060. isLuminance: boolean;
  105061. /**
  105062. * If this is a cube texture
  105063. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105064. */
  105065. isCube: boolean;
  105066. /**
  105067. * If the texture is a compressed format eg. FOURCC_DXT1
  105068. */
  105069. isCompressed: boolean;
  105070. /**
  105071. * The dxgiFormat of the texture
  105072. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105073. */
  105074. dxgiFormat: number;
  105075. /**
  105076. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105077. */
  105078. textureType: number;
  105079. /**
  105080. * Sphericle polynomial created for the dds texture
  105081. */
  105082. sphericalPolynomial?: SphericalPolynomial;
  105083. }
  105084. /**
  105085. * Class used to provide DDS decompression tools
  105086. */
  105087. export class DDSTools {
  105088. /**
  105089. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105090. */
  105091. static StoreLODInAlphaChannel: boolean;
  105092. /**
  105093. * Gets DDS information from an array buffer
  105094. * @param arrayBuffer defines the array buffer to read data from
  105095. * @returns the DDS information
  105096. */
  105097. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105098. private static _FloatView;
  105099. private static _Int32View;
  105100. private static _ToHalfFloat;
  105101. private static _FromHalfFloat;
  105102. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105103. private static _GetHalfFloatRGBAArrayBuffer;
  105104. private static _GetFloatRGBAArrayBuffer;
  105105. private static _GetFloatAsUIntRGBAArrayBuffer;
  105106. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105107. private static _GetRGBAArrayBuffer;
  105108. private static _ExtractLongWordOrder;
  105109. private static _GetRGBArrayBuffer;
  105110. private static _GetLuminanceArrayBuffer;
  105111. /**
  105112. * Uploads DDS Levels to a Babylon Texture
  105113. * @hidden
  105114. */
  105115. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105116. }
  105117. interface Engine {
  105118. /**
  105119. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105120. * @param rootUrl defines the url where the file to load is located
  105121. * @param scene defines the current scene
  105122. * @param lodScale defines scale to apply to the mip map selection
  105123. * @param lodOffset defines offset to apply to the mip map selection
  105124. * @param onLoad defines an optional callback raised when the texture is loaded
  105125. * @param onError defines an optional callback raised if there is an issue to load the texture
  105126. * @param format defines the format of the data
  105127. * @param forcedExtension defines the extension to use to pick the right loader
  105128. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105129. * @returns the cube texture as an InternalTexture
  105130. */
  105131. 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;
  105132. }
  105133. }
  105134. declare module BABYLON {
  105135. /**
  105136. * Implementation of the DDS Texture Loader.
  105137. * @hidden
  105138. */
  105139. export class _DDSTextureLoader implements IInternalTextureLoader {
  105140. /**
  105141. * Defines wether the loader supports cascade loading the different faces.
  105142. */
  105143. readonly supportCascades: boolean;
  105144. /**
  105145. * This returns if the loader support the current file information.
  105146. * @param extension defines the file extension of the file being loaded
  105147. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105148. * @param fallback defines the fallback internal texture if any
  105149. * @param isBase64 defines whether the texture is encoded as a base64
  105150. * @param isBuffer defines whether the texture data are stored as a buffer
  105151. * @returns true if the loader can load the specified file
  105152. */
  105153. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105154. /**
  105155. * Transform the url before loading if required.
  105156. * @param rootUrl the url of the texture
  105157. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105158. * @returns the transformed texture
  105159. */
  105160. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105161. /**
  105162. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105163. * @param rootUrl the url of the texture
  105164. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105165. * @returns the fallback texture
  105166. */
  105167. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105168. /**
  105169. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105170. * @param data contains the texture data
  105171. * @param texture defines the BabylonJS internal texture
  105172. * @param createPolynomials will be true if polynomials have been requested
  105173. * @param onLoad defines the callback to trigger once the texture is ready
  105174. * @param onError defines the callback to trigger in case of error
  105175. */
  105176. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105177. /**
  105178. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105179. * @param data contains the texture data
  105180. * @param texture defines the BabylonJS internal texture
  105181. * @param callback defines the method to call once ready to upload
  105182. */
  105183. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105184. }
  105185. }
  105186. declare module BABYLON {
  105187. /** @hidden */
  105188. export var rgbdEncodePixelShader: {
  105189. name: string;
  105190. shader: string;
  105191. };
  105192. }
  105193. declare module BABYLON {
  105194. /**
  105195. * Raw texture data and descriptor sufficient for WebGL texture upload
  105196. */
  105197. export interface EnvironmentTextureInfo {
  105198. /**
  105199. * Version of the environment map
  105200. */
  105201. version: number;
  105202. /**
  105203. * Width of image
  105204. */
  105205. width: number;
  105206. /**
  105207. * Irradiance information stored in the file.
  105208. */
  105209. irradiance: any;
  105210. /**
  105211. * Specular information stored in the file.
  105212. */
  105213. specular: any;
  105214. }
  105215. /**
  105216. * Sets of helpers addressing the serialization and deserialization of environment texture
  105217. * stored in a BabylonJS env file.
  105218. * Those files are usually stored as .env files.
  105219. */
  105220. export class EnvironmentTextureTools {
  105221. /**
  105222. * Magic number identifying the env file.
  105223. */
  105224. private static _MagicBytes;
  105225. /**
  105226. * Gets the environment info from an env file.
  105227. * @param data The array buffer containing the .env bytes.
  105228. * @returns the environment file info (the json header) if successfully parsed.
  105229. */
  105230. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105231. /**
  105232. * Creates an environment texture from a loaded cube texture.
  105233. * @param texture defines the cube texture to convert in env file
  105234. * @return a promise containing the environment data if succesfull.
  105235. */
  105236. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105237. /**
  105238. * Creates a JSON representation of the spherical data.
  105239. * @param texture defines the texture containing the polynomials
  105240. * @return the JSON representation of the spherical info
  105241. */
  105242. private static _CreateEnvTextureIrradiance;
  105243. /**
  105244. * Uploads the texture info contained in the env file to the GPU.
  105245. * @param texture defines the internal texture to upload to
  105246. * @param arrayBuffer defines the buffer cotaining the data to load
  105247. * @param info defines the texture info retrieved through the GetEnvInfo method
  105248. * @returns a promise
  105249. */
  105250. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105251. /**
  105252. * Uploads the levels of image data to the GPU.
  105253. * @param texture defines the internal texture to upload to
  105254. * @param imageData defines the array buffer views of image data [mipmap][face]
  105255. * @returns a promise
  105256. */
  105257. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105258. /**
  105259. * Uploads spherical polynomials information to the texture.
  105260. * @param texture defines the texture we are trying to upload the information to
  105261. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105262. */
  105263. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105264. /** @hidden */
  105265. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105266. }
  105267. }
  105268. declare module BABYLON {
  105269. /**
  105270. * Implementation of the ENV Texture Loader.
  105271. * @hidden
  105272. */
  105273. export class _ENVTextureLoader implements IInternalTextureLoader {
  105274. /**
  105275. * Defines wether the loader supports cascade loading the different faces.
  105276. */
  105277. readonly supportCascades: boolean;
  105278. /**
  105279. * This returns if the loader support the current file information.
  105280. * @param extension defines the file extension of the file being loaded
  105281. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105282. * @param fallback defines the fallback internal texture if any
  105283. * @param isBase64 defines whether the texture is encoded as a base64
  105284. * @param isBuffer defines whether the texture data are stored as a buffer
  105285. * @returns true if the loader can load the specified file
  105286. */
  105287. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105288. /**
  105289. * Transform the url before loading if required.
  105290. * @param rootUrl the url of the texture
  105291. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105292. * @returns the transformed texture
  105293. */
  105294. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105295. /**
  105296. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105297. * @param rootUrl the url of the texture
  105298. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105299. * @returns the fallback texture
  105300. */
  105301. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105302. /**
  105303. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105304. * @param data contains the texture data
  105305. * @param texture defines the BabylonJS internal texture
  105306. * @param createPolynomials will be true if polynomials have been requested
  105307. * @param onLoad defines the callback to trigger once the texture is ready
  105308. * @param onError defines the callback to trigger in case of error
  105309. */
  105310. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105311. /**
  105312. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105313. * @param data contains the texture data
  105314. * @param texture defines the BabylonJS internal texture
  105315. * @param callback defines the method to call once ready to upload
  105316. */
  105317. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105318. }
  105319. }
  105320. declare module BABYLON {
  105321. /**
  105322. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105323. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105324. */
  105325. export class KhronosTextureContainer {
  105326. /** contents of the KTX container file */
  105327. arrayBuffer: any;
  105328. private static HEADER_LEN;
  105329. private static COMPRESSED_2D;
  105330. private static COMPRESSED_3D;
  105331. private static TEX_2D;
  105332. private static TEX_3D;
  105333. /**
  105334. * Gets the openGL type
  105335. */
  105336. glType: number;
  105337. /**
  105338. * Gets the openGL type size
  105339. */
  105340. glTypeSize: number;
  105341. /**
  105342. * Gets the openGL format
  105343. */
  105344. glFormat: number;
  105345. /**
  105346. * Gets the openGL internal format
  105347. */
  105348. glInternalFormat: number;
  105349. /**
  105350. * Gets the base internal format
  105351. */
  105352. glBaseInternalFormat: number;
  105353. /**
  105354. * Gets image width in pixel
  105355. */
  105356. pixelWidth: number;
  105357. /**
  105358. * Gets image height in pixel
  105359. */
  105360. pixelHeight: number;
  105361. /**
  105362. * Gets image depth in pixels
  105363. */
  105364. pixelDepth: number;
  105365. /**
  105366. * Gets the number of array elements
  105367. */
  105368. numberOfArrayElements: number;
  105369. /**
  105370. * Gets the number of faces
  105371. */
  105372. numberOfFaces: number;
  105373. /**
  105374. * Gets the number of mipmap levels
  105375. */
  105376. numberOfMipmapLevels: number;
  105377. /**
  105378. * Gets the bytes of key value data
  105379. */
  105380. bytesOfKeyValueData: number;
  105381. /**
  105382. * Gets the load type
  105383. */
  105384. loadType: number;
  105385. /**
  105386. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105387. */
  105388. isInvalid: boolean;
  105389. /**
  105390. * Creates a new KhronosTextureContainer
  105391. * @param arrayBuffer contents of the KTX container file
  105392. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105393. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105394. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105395. */
  105396. constructor(
  105397. /** contents of the KTX container file */
  105398. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105399. /**
  105400. * Uploads KTX content to a Babylon Texture.
  105401. * It is assumed that the texture has already been created & is currently bound
  105402. * @hidden
  105403. */
  105404. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105405. private _upload2DCompressedLevels;
  105406. }
  105407. }
  105408. declare module BABYLON {
  105409. /**
  105410. * Implementation of the KTX Texture Loader.
  105411. * @hidden
  105412. */
  105413. export class _KTXTextureLoader implements IInternalTextureLoader {
  105414. /**
  105415. * Defines wether the loader supports cascade loading the different faces.
  105416. */
  105417. readonly supportCascades: boolean;
  105418. /**
  105419. * This returns if the loader support the current file information.
  105420. * @param extension defines the file extension of the file being loaded
  105421. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105422. * @param fallback defines the fallback internal texture if any
  105423. * @param isBase64 defines whether the texture is encoded as a base64
  105424. * @param isBuffer defines whether the texture data are stored as a buffer
  105425. * @returns true if the loader can load the specified file
  105426. */
  105427. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105428. /**
  105429. * Transform the url before loading if required.
  105430. * @param rootUrl the url of the texture
  105431. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105432. * @returns the transformed texture
  105433. */
  105434. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105435. /**
  105436. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105437. * @param rootUrl the url of the texture
  105438. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105439. * @returns the fallback texture
  105440. */
  105441. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105442. /**
  105443. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105444. * @param data contains the texture data
  105445. * @param texture defines the BabylonJS internal texture
  105446. * @param createPolynomials will be true if polynomials have been requested
  105447. * @param onLoad defines the callback to trigger once the texture is ready
  105448. * @param onError defines the callback to trigger in case of error
  105449. */
  105450. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105451. /**
  105452. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105453. * @param data contains the texture data
  105454. * @param texture defines the BabylonJS internal texture
  105455. * @param callback defines the method to call once ready to upload
  105456. */
  105457. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105458. }
  105459. }
  105460. declare module BABYLON {
  105461. /** @hidden */
  105462. export var _forceSceneHelpersToBundle: boolean;
  105463. interface Scene {
  105464. /**
  105465. * Creates a default light for the scene.
  105466. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105467. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105468. */
  105469. createDefaultLight(replace?: boolean): void;
  105470. /**
  105471. * Creates a default camera for the scene.
  105472. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105473. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105474. * @param replace has default false, when true replaces the active camera in the scene
  105475. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105476. */
  105477. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105478. /**
  105479. * Creates a default camera and a default light.
  105480. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105481. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105482. * @param replace has the default false, when true replaces the active camera/light in the scene
  105483. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105484. */
  105485. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105486. /**
  105487. * Creates a new sky box
  105488. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105489. * @param environmentTexture defines the texture to use as environment texture
  105490. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105491. * @param scale defines the overall scale of the skybox
  105492. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105493. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105494. * @returns a new mesh holding the sky box
  105495. */
  105496. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105497. /**
  105498. * Creates a new environment
  105499. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105500. * @param options defines the options you can use to configure the environment
  105501. * @returns the new EnvironmentHelper
  105502. */
  105503. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105504. /**
  105505. * Creates a new VREXperienceHelper
  105506. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105507. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105508. * @returns a new VREXperienceHelper
  105509. */
  105510. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105511. /**
  105512. * Creates a new XREXperienceHelper
  105513. * @see http://doc.babylonjs.com/how_to/webxr
  105514. * @returns a promise for a new XREXperienceHelper
  105515. */
  105516. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105517. }
  105518. }
  105519. declare module BABYLON {
  105520. /**
  105521. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105522. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105523. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105524. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105525. */
  105526. export class VideoDome extends TransformNode {
  105527. /**
  105528. * Define the video source as a Monoscopic panoramic 360 video.
  105529. */
  105530. static readonly MODE_MONOSCOPIC: number;
  105531. /**
  105532. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105533. */
  105534. static readonly MODE_TOPBOTTOM: number;
  105535. /**
  105536. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105537. */
  105538. static readonly MODE_SIDEBYSIDE: number;
  105539. private _useDirectMapping;
  105540. /**
  105541. * The video texture being displayed on the sphere
  105542. */
  105543. protected _videoTexture: VideoTexture;
  105544. /**
  105545. * Gets the video texture being displayed on the sphere
  105546. */
  105547. readonly videoTexture: VideoTexture;
  105548. /**
  105549. * The skybox material
  105550. */
  105551. protected _material: BackgroundMaterial;
  105552. /**
  105553. * The surface used for the skybox
  105554. */
  105555. protected _mesh: Mesh;
  105556. /**
  105557. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105558. * Also see the options.resolution property.
  105559. */
  105560. fovMultiplier: number;
  105561. private _videoMode;
  105562. /**
  105563. * Gets or set the current video mode for the video. It can be:
  105564. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105565. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105566. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105567. */
  105568. videoMode: number;
  105569. /**
  105570. * Oberserver used in Stereoscopic VR Mode.
  105571. */
  105572. private _onBeforeCameraRenderObserver;
  105573. /**
  105574. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105575. * @param name Element's name, child elements will append suffixes for their own names.
  105576. * @param urlsOrVideo defines the url(s) or the video element to use
  105577. * @param options An object containing optional or exposed sub element properties
  105578. */
  105579. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105580. resolution?: number;
  105581. clickToPlay?: boolean;
  105582. autoPlay?: boolean;
  105583. loop?: boolean;
  105584. size?: number;
  105585. poster?: string;
  105586. faceForward?: boolean;
  105587. useDirectMapping?: boolean;
  105588. }, scene: Scene);
  105589. private _changeVideoMode;
  105590. /**
  105591. * Releases resources associated with this node.
  105592. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105593. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105594. */
  105595. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105596. }
  105597. }
  105598. declare module BABYLON {
  105599. /**
  105600. * This class can be used to get instrumentation data from a Babylon engine
  105601. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105602. */
  105603. export class EngineInstrumentation implements IDisposable {
  105604. /**
  105605. * Define the instrumented engine.
  105606. */
  105607. engine: Engine;
  105608. private _captureGPUFrameTime;
  105609. private _gpuFrameTimeToken;
  105610. private _gpuFrameTime;
  105611. private _captureShaderCompilationTime;
  105612. private _shaderCompilationTime;
  105613. private _onBeginFrameObserver;
  105614. private _onEndFrameObserver;
  105615. private _onBeforeShaderCompilationObserver;
  105616. private _onAfterShaderCompilationObserver;
  105617. /**
  105618. * Gets the perf counter used for GPU frame time
  105619. */
  105620. readonly gpuFrameTimeCounter: PerfCounter;
  105621. /**
  105622. * Gets the GPU frame time capture status
  105623. */
  105624. /**
  105625. * Enable or disable the GPU frame time capture
  105626. */
  105627. captureGPUFrameTime: boolean;
  105628. /**
  105629. * Gets the perf counter used for shader compilation time
  105630. */
  105631. readonly shaderCompilationTimeCounter: PerfCounter;
  105632. /**
  105633. * Gets the shader compilation time capture status
  105634. */
  105635. /**
  105636. * Enable or disable the shader compilation time capture
  105637. */
  105638. captureShaderCompilationTime: boolean;
  105639. /**
  105640. * Instantiates a new engine instrumentation.
  105641. * This class can be used to get instrumentation data from a Babylon engine
  105642. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105643. * @param engine Defines the engine to instrument
  105644. */
  105645. constructor(
  105646. /**
  105647. * Define the instrumented engine.
  105648. */
  105649. engine: Engine);
  105650. /**
  105651. * Dispose and release associated resources.
  105652. */
  105653. dispose(): void;
  105654. }
  105655. }
  105656. declare module BABYLON {
  105657. /**
  105658. * This class can be used to get instrumentation data from a Babylon engine
  105659. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105660. */
  105661. export class SceneInstrumentation implements IDisposable {
  105662. /**
  105663. * Defines the scene to instrument
  105664. */
  105665. scene: Scene;
  105666. private _captureActiveMeshesEvaluationTime;
  105667. private _activeMeshesEvaluationTime;
  105668. private _captureRenderTargetsRenderTime;
  105669. private _renderTargetsRenderTime;
  105670. private _captureFrameTime;
  105671. private _frameTime;
  105672. private _captureRenderTime;
  105673. private _renderTime;
  105674. private _captureInterFrameTime;
  105675. private _interFrameTime;
  105676. private _captureParticlesRenderTime;
  105677. private _particlesRenderTime;
  105678. private _captureSpritesRenderTime;
  105679. private _spritesRenderTime;
  105680. private _capturePhysicsTime;
  105681. private _physicsTime;
  105682. private _captureAnimationsTime;
  105683. private _animationsTime;
  105684. private _captureCameraRenderTime;
  105685. private _cameraRenderTime;
  105686. private _onBeforeActiveMeshesEvaluationObserver;
  105687. private _onAfterActiveMeshesEvaluationObserver;
  105688. private _onBeforeRenderTargetsRenderObserver;
  105689. private _onAfterRenderTargetsRenderObserver;
  105690. private _onAfterRenderObserver;
  105691. private _onBeforeDrawPhaseObserver;
  105692. private _onAfterDrawPhaseObserver;
  105693. private _onBeforeAnimationsObserver;
  105694. private _onBeforeParticlesRenderingObserver;
  105695. private _onAfterParticlesRenderingObserver;
  105696. private _onBeforeSpritesRenderingObserver;
  105697. private _onAfterSpritesRenderingObserver;
  105698. private _onBeforePhysicsObserver;
  105699. private _onAfterPhysicsObserver;
  105700. private _onAfterAnimationsObserver;
  105701. private _onBeforeCameraRenderObserver;
  105702. private _onAfterCameraRenderObserver;
  105703. /**
  105704. * Gets the perf counter used for active meshes evaluation time
  105705. */
  105706. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105707. /**
  105708. * Gets the active meshes evaluation time capture status
  105709. */
  105710. /**
  105711. * Enable or disable the active meshes evaluation time capture
  105712. */
  105713. captureActiveMeshesEvaluationTime: boolean;
  105714. /**
  105715. * Gets the perf counter used for render targets render time
  105716. */
  105717. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105718. /**
  105719. * Gets the render targets render time capture status
  105720. */
  105721. /**
  105722. * Enable or disable the render targets render time capture
  105723. */
  105724. captureRenderTargetsRenderTime: boolean;
  105725. /**
  105726. * Gets the perf counter used for particles render time
  105727. */
  105728. readonly particlesRenderTimeCounter: PerfCounter;
  105729. /**
  105730. * Gets the particles render time capture status
  105731. */
  105732. /**
  105733. * Enable or disable the particles render time capture
  105734. */
  105735. captureParticlesRenderTime: boolean;
  105736. /**
  105737. * Gets the perf counter used for sprites render time
  105738. */
  105739. readonly spritesRenderTimeCounter: PerfCounter;
  105740. /**
  105741. * Gets the sprites render time capture status
  105742. */
  105743. /**
  105744. * Enable or disable the sprites render time capture
  105745. */
  105746. captureSpritesRenderTime: boolean;
  105747. /**
  105748. * Gets the perf counter used for physics time
  105749. */
  105750. readonly physicsTimeCounter: PerfCounter;
  105751. /**
  105752. * Gets the physics time capture status
  105753. */
  105754. /**
  105755. * Enable or disable the physics time capture
  105756. */
  105757. capturePhysicsTime: boolean;
  105758. /**
  105759. * Gets the perf counter used for animations time
  105760. */
  105761. readonly animationsTimeCounter: PerfCounter;
  105762. /**
  105763. * Gets the animations time capture status
  105764. */
  105765. /**
  105766. * Enable or disable the animations time capture
  105767. */
  105768. captureAnimationsTime: boolean;
  105769. /**
  105770. * Gets the perf counter used for frame time capture
  105771. */
  105772. readonly frameTimeCounter: PerfCounter;
  105773. /**
  105774. * Gets the frame time capture status
  105775. */
  105776. /**
  105777. * Enable or disable the frame time capture
  105778. */
  105779. captureFrameTime: boolean;
  105780. /**
  105781. * Gets the perf counter used for inter-frames time capture
  105782. */
  105783. readonly interFrameTimeCounter: PerfCounter;
  105784. /**
  105785. * Gets the inter-frames time capture status
  105786. */
  105787. /**
  105788. * Enable or disable the inter-frames time capture
  105789. */
  105790. captureInterFrameTime: boolean;
  105791. /**
  105792. * Gets the perf counter used for render time capture
  105793. */
  105794. readonly renderTimeCounter: PerfCounter;
  105795. /**
  105796. * Gets the render time capture status
  105797. */
  105798. /**
  105799. * Enable or disable the render time capture
  105800. */
  105801. captureRenderTime: boolean;
  105802. /**
  105803. * Gets the perf counter used for camera render time capture
  105804. */
  105805. readonly cameraRenderTimeCounter: PerfCounter;
  105806. /**
  105807. * Gets the camera render time capture status
  105808. */
  105809. /**
  105810. * Enable or disable the camera render time capture
  105811. */
  105812. captureCameraRenderTime: boolean;
  105813. /**
  105814. * Gets the perf counter used for draw calls
  105815. */
  105816. readonly drawCallsCounter: PerfCounter;
  105817. /**
  105818. * Instantiates a new scene instrumentation.
  105819. * This class can be used to get instrumentation data from a Babylon engine
  105820. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105821. * @param scene Defines the scene to instrument
  105822. */
  105823. constructor(
  105824. /**
  105825. * Defines the scene to instrument
  105826. */
  105827. scene: Scene);
  105828. /**
  105829. * Dispose and release associated resources.
  105830. */
  105831. dispose(): void;
  105832. }
  105833. }
  105834. declare module BABYLON {
  105835. /** @hidden */
  105836. export var glowMapGenerationPixelShader: {
  105837. name: string;
  105838. shader: string;
  105839. };
  105840. }
  105841. declare module BABYLON {
  105842. /** @hidden */
  105843. export var glowMapGenerationVertexShader: {
  105844. name: string;
  105845. shader: string;
  105846. };
  105847. }
  105848. declare module BABYLON {
  105849. /**
  105850. * Effect layer options. This helps customizing the behaviour
  105851. * of the effect layer.
  105852. */
  105853. export interface IEffectLayerOptions {
  105854. /**
  105855. * Multiplication factor apply to the canvas size to compute the render target size
  105856. * used to generated the objects (the smaller the faster).
  105857. */
  105858. mainTextureRatio: number;
  105859. /**
  105860. * Enforces a fixed size texture to ensure effect stability across devices.
  105861. */
  105862. mainTextureFixedSize?: number;
  105863. /**
  105864. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  105865. */
  105866. alphaBlendingMode: number;
  105867. /**
  105868. * The camera attached to the layer.
  105869. */
  105870. camera: Nullable<Camera>;
  105871. /**
  105872. * The rendering group to draw the layer in.
  105873. */
  105874. renderingGroupId: number;
  105875. }
  105876. /**
  105877. * The effect layer Helps adding post process effect blended with the main pass.
  105878. *
  105879. * This can be for instance use to generate glow or higlight effects on the scene.
  105880. *
  105881. * The effect layer class can not be used directly and is intented to inherited from to be
  105882. * customized per effects.
  105883. */
  105884. export abstract class EffectLayer {
  105885. private _vertexBuffers;
  105886. private _indexBuffer;
  105887. private _cachedDefines;
  105888. private _effectLayerMapGenerationEffect;
  105889. private _effectLayerOptions;
  105890. private _mergeEffect;
  105891. protected _scene: Scene;
  105892. protected _engine: Engine;
  105893. protected _maxSize: number;
  105894. protected _mainTextureDesiredSize: ISize;
  105895. protected _mainTexture: RenderTargetTexture;
  105896. protected _shouldRender: boolean;
  105897. protected _postProcesses: PostProcess[];
  105898. protected _textures: BaseTexture[];
  105899. protected _emissiveTextureAndColor: {
  105900. texture: Nullable<BaseTexture>;
  105901. color: Color4;
  105902. };
  105903. /**
  105904. * The name of the layer
  105905. */
  105906. name: string;
  105907. /**
  105908. * The clear color of the texture used to generate the glow map.
  105909. */
  105910. neutralColor: Color4;
  105911. /**
  105912. * Specifies wether the highlight layer is enabled or not.
  105913. */
  105914. isEnabled: boolean;
  105915. /**
  105916. * Gets the camera attached to the layer.
  105917. */
  105918. readonly camera: Nullable<Camera>;
  105919. /**
  105920. * Gets the rendering group id the layer should render in.
  105921. */
  105922. readonly renderingGroupId: number;
  105923. /**
  105924. * An event triggered when the effect layer has been disposed.
  105925. */
  105926. onDisposeObservable: Observable<EffectLayer>;
  105927. /**
  105928. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  105929. */
  105930. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  105931. /**
  105932. * An event triggered when the generated texture is being merged in the scene.
  105933. */
  105934. onBeforeComposeObservable: Observable<EffectLayer>;
  105935. /**
  105936. * An event triggered when the generated texture has been merged in the scene.
  105937. */
  105938. onAfterComposeObservable: Observable<EffectLayer>;
  105939. /**
  105940. * An event triggered when the efffect layer changes its size.
  105941. */
  105942. onSizeChangedObservable: Observable<EffectLayer>;
  105943. /** @hidden */
  105944. static _SceneComponentInitialization: (scene: Scene) => void;
  105945. /**
  105946. * Instantiates a new effect Layer and references it in the scene.
  105947. * @param name The name of the layer
  105948. * @param scene The scene to use the layer in
  105949. */
  105950. constructor(
  105951. /** The Friendly of the effect in the scene */
  105952. name: string, scene: Scene);
  105953. /**
  105954. * Get the effect name of the layer.
  105955. * @return The effect name
  105956. */
  105957. abstract getEffectName(): string;
  105958. /**
  105959. * Checks for the readiness of the element composing the layer.
  105960. * @param subMesh the mesh to check for
  105961. * @param useInstances specify wether or not to use instances to render the mesh
  105962. * @return true if ready otherwise, false
  105963. */
  105964. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  105965. /**
  105966. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  105967. * @returns true if the effect requires stencil during the main canvas render pass.
  105968. */
  105969. abstract needStencil(): boolean;
  105970. /**
  105971. * Create the merge effect. This is the shader use to blit the information back
  105972. * to the main canvas at the end of the scene rendering.
  105973. * @returns The effect containing the shader used to merge the effect on the main canvas
  105974. */
  105975. protected abstract _createMergeEffect(): Effect;
  105976. /**
  105977. * Creates the render target textures and post processes used in the effect layer.
  105978. */
  105979. protected abstract _createTextureAndPostProcesses(): void;
  105980. /**
  105981. * Implementation specific of rendering the generating effect on the main canvas.
  105982. * @param effect The effect used to render through
  105983. */
  105984. protected abstract _internalRender(effect: Effect): void;
  105985. /**
  105986. * Sets the required values for both the emissive texture and and the main color.
  105987. */
  105988. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  105989. /**
  105990. * Free any resources and references associated to a mesh.
  105991. * Internal use
  105992. * @param mesh The mesh to free.
  105993. */
  105994. abstract _disposeMesh(mesh: Mesh): void;
  105995. /**
  105996. * Serializes this layer (Glow or Highlight for example)
  105997. * @returns a serialized layer object
  105998. */
  105999. abstract serialize?(): any;
  106000. /**
  106001. * Initializes the effect layer with the required options.
  106002. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106003. */
  106004. protected _init(options: Partial<IEffectLayerOptions>): void;
  106005. /**
  106006. * Generates the index buffer of the full screen quad blending to the main canvas.
  106007. */
  106008. private _generateIndexBuffer;
  106009. /**
  106010. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106011. */
  106012. private _genrateVertexBuffer;
  106013. /**
  106014. * Sets the main texture desired size which is the closest power of two
  106015. * of the engine canvas size.
  106016. */
  106017. private _setMainTextureSize;
  106018. /**
  106019. * Creates the main texture for the effect layer.
  106020. */
  106021. protected _createMainTexture(): void;
  106022. /**
  106023. * Adds specific effects defines.
  106024. * @param defines The defines to add specifics to.
  106025. */
  106026. protected _addCustomEffectDefines(defines: string[]): void;
  106027. /**
  106028. * Checks for the readiness of the element composing the layer.
  106029. * @param subMesh the mesh to check for
  106030. * @param useInstances specify wether or not to use instances to render the mesh
  106031. * @param emissiveTexture the associated emissive texture used to generate the glow
  106032. * @return true if ready otherwise, false
  106033. */
  106034. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106035. /**
  106036. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106037. */
  106038. render(): void;
  106039. /**
  106040. * Determine if a given mesh will be used in the current effect.
  106041. * @param mesh mesh to test
  106042. * @returns true if the mesh will be used
  106043. */
  106044. hasMesh(mesh: AbstractMesh): boolean;
  106045. /**
  106046. * Returns true if the layer contains information to display, otherwise false.
  106047. * @returns true if the glow layer should be rendered
  106048. */
  106049. shouldRender(): boolean;
  106050. /**
  106051. * Returns true if the mesh should render, otherwise false.
  106052. * @param mesh The mesh to render
  106053. * @returns true if it should render otherwise false
  106054. */
  106055. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106056. /**
  106057. * Returns true if the mesh can be rendered, otherwise false.
  106058. * @param mesh The mesh to render
  106059. * @param material The material used on the mesh
  106060. * @returns true if it can be rendered otherwise false
  106061. */
  106062. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106063. /**
  106064. * Returns true if the mesh should render, otherwise false.
  106065. * @param mesh The mesh to render
  106066. * @returns true if it should render otherwise false
  106067. */
  106068. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106069. /**
  106070. * Renders the submesh passed in parameter to the generation map.
  106071. */
  106072. protected _renderSubMesh(subMesh: SubMesh): void;
  106073. /**
  106074. * Rebuild the required buffers.
  106075. * @hidden Internal use only.
  106076. */
  106077. _rebuild(): void;
  106078. /**
  106079. * Dispose only the render target textures and post process.
  106080. */
  106081. private _disposeTextureAndPostProcesses;
  106082. /**
  106083. * Dispose the highlight layer and free resources.
  106084. */
  106085. dispose(): void;
  106086. /**
  106087. * Gets the class name of the effect layer
  106088. * @returns the string with the class name of the effect layer
  106089. */
  106090. getClassName(): string;
  106091. /**
  106092. * Creates an effect layer from parsed effect layer data
  106093. * @param parsedEffectLayer defines effect layer data
  106094. * @param scene defines the current scene
  106095. * @param rootUrl defines the root URL containing the effect layer information
  106096. * @returns a parsed effect Layer
  106097. */
  106098. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106099. }
  106100. }
  106101. declare module BABYLON {
  106102. interface AbstractScene {
  106103. /**
  106104. * The list of effect layers (highlights/glow) added to the scene
  106105. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106106. * @see http://doc.babylonjs.com/how_to/glow_layer
  106107. */
  106108. effectLayers: Array<EffectLayer>;
  106109. /**
  106110. * Removes the given effect layer from this scene.
  106111. * @param toRemove defines the effect layer to remove
  106112. * @returns the index of the removed effect layer
  106113. */
  106114. removeEffectLayer(toRemove: EffectLayer): number;
  106115. /**
  106116. * Adds the given effect layer to this scene
  106117. * @param newEffectLayer defines the effect layer to add
  106118. */
  106119. addEffectLayer(newEffectLayer: EffectLayer): void;
  106120. }
  106121. /**
  106122. * Defines the layer scene component responsible to manage any effect layers
  106123. * in a given scene.
  106124. */
  106125. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106126. /**
  106127. * The component name helpfull to identify the component in the list of scene components.
  106128. */
  106129. readonly name: string;
  106130. /**
  106131. * The scene the component belongs to.
  106132. */
  106133. scene: Scene;
  106134. private _engine;
  106135. private _renderEffects;
  106136. private _needStencil;
  106137. private _previousStencilState;
  106138. /**
  106139. * Creates a new instance of the component for the given scene
  106140. * @param scene Defines the scene to register the component in
  106141. */
  106142. constructor(scene: Scene);
  106143. /**
  106144. * Registers the component in a given scene
  106145. */
  106146. register(): void;
  106147. /**
  106148. * Rebuilds the elements related to this component in case of
  106149. * context lost for instance.
  106150. */
  106151. rebuild(): void;
  106152. /**
  106153. * Serializes the component data to the specified json object
  106154. * @param serializationObject The object to serialize to
  106155. */
  106156. serialize(serializationObject: any): void;
  106157. /**
  106158. * Adds all the element from the container to the scene
  106159. * @param container the container holding the elements
  106160. */
  106161. addFromContainer(container: AbstractScene): void;
  106162. /**
  106163. * Removes all the elements in the container from the scene
  106164. * @param container contains the elements to remove
  106165. * @param dispose if the removed element should be disposed (default: false)
  106166. */
  106167. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106168. /**
  106169. * Disposes the component and the associated ressources.
  106170. */
  106171. dispose(): void;
  106172. private _isReadyForMesh;
  106173. private _renderMainTexture;
  106174. private _setStencil;
  106175. private _setStencilBack;
  106176. private _draw;
  106177. private _drawCamera;
  106178. private _drawRenderingGroup;
  106179. }
  106180. }
  106181. declare module BABYLON {
  106182. /** @hidden */
  106183. export var glowMapMergePixelShader: {
  106184. name: string;
  106185. shader: string;
  106186. };
  106187. }
  106188. declare module BABYLON {
  106189. /** @hidden */
  106190. export var glowMapMergeVertexShader: {
  106191. name: string;
  106192. shader: string;
  106193. };
  106194. }
  106195. declare module BABYLON {
  106196. interface AbstractScene {
  106197. /**
  106198. * Return a the first highlight layer of the scene with a given name.
  106199. * @param name The name of the highlight layer to look for.
  106200. * @return The highlight layer if found otherwise null.
  106201. */
  106202. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106203. }
  106204. /**
  106205. * Glow layer options. This helps customizing the behaviour
  106206. * of the glow layer.
  106207. */
  106208. export interface IGlowLayerOptions {
  106209. /**
  106210. * Multiplication factor apply to the canvas size to compute the render target size
  106211. * used to generated the glowing objects (the smaller the faster).
  106212. */
  106213. mainTextureRatio: number;
  106214. /**
  106215. * Enforces a fixed size texture to ensure resize independant blur.
  106216. */
  106217. mainTextureFixedSize?: number;
  106218. /**
  106219. * How big is the kernel of the blur texture.
  106220. */
  106221. blurKernelSize: number;
  106222. /**
  106223. * The camera attached to the layer.
  106224. */
  106225. camera: Nullable<Camera>;
  106226. /**
  106227. * Enable MSAA by chosing the number of samples.
  106228. */
  106229. mainTextureSamples?: number;
  106230. /**
  106231. * The rendering group to draw the layer in.
  106232. */
  106233. renderingGroupId: number;
  106234. }
  106235. /**
  106236. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106237. *
  106238. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106239. * glowy meshes to your scene.
  106240. *
  106241. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106242. */
  106243. export class GlowLayer extends EffectLayer {
  106244. /**
  106245. * Effect Name of the layer.
  106246. */
  106247. static readonly EffectName: string;
  106248. /**
  106249. * The default blur kernel size used for the glow.
  106250. */
  106251. static DefaultBlurKernelSize: number;
  106252. /**
  106253. * The default texture size ratio used for the glow.
  106254. */
  106255. static DefaultTextureRatio: number;
  106256. /**
  106257. * Sets the kernel size of the blur.
  106258. */
  106259. /**
  106260. * Gets the kernel size of the blur.
  106261. */
  106262. blurKernelSize: number;
  106263. /**
  106264. * Sets the glow intensity.
  106265. */
  106266. /**
  106267. * Gets the glow intensity.
  106268. */
  106269. intensity: number;
  106270. private _options;
  106271. private _intensity;
  106272. private _horizontalBlurPostprocess1;
  106273. private _verticalBlurPostprocess1;
  106274. private _horizontalBlurPostprocess2;
  106275. private _verticalBlurPostprocess2;
  106276. private _blurTexture1;
  106277. private _blurTexture2;
  106278. private _postProcesses1;
  106279. private _postProcesses2;
  106280. private _includedOnlyMeshes;
  106281. private _excludedMeshes;
  106282. /**
  106283. * Callback used to let the user override the color selection on a per mesh basis
  106284. */
  106285. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106286. /**
  106287. * Callback used to let the user override the texture selection on a per mesh basis
  106288. */
  106289. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106290. /**
  106291. * Instantiates a new glow Layer and references it to the scene.
  106292. * @param name The name of the layer
  106293. * @param scene The scene to use the layer in
  106294. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106295. */
  106296. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106297. /**
  106298. * Get the effect name of the layer.
  106299. * @return The effect name
  106300. */
  106301. getEffectName(): string;
  106302. /**
  106303. * Create the merge effect. This is the shader use to blit the information back
  106304. * to the main canvas at the end of the scene rendering.
  106305. */
  106306. protected _createMergeEffect(): Effect;
  106307. /**
  106308. * Creates the render target textures and post processes used in the glow layer.
  106309. */
  106310. protected _createTextureAndPostProcesses(): void;
  106311. /**
  106312. * Checks for the readiness of the element composing the layer.
  106313. * @param subMesh the mesh to check for
  106314. * @param useInstances specify wether or not to use instances to render the mesh
  106315. * @param emissiveTexture the associated emissive texture used to generate the glow
  106316. * @return true if ready otherwise, false
  106317. */
  106318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106319. /**
  106320. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106321. */
  106322. needStencil(): boolean;
  106323. /**
  106324. * Returns true if the mesh can be rendered, otherwise false.
  106325. * @param mesh The mesh to render
  106326. * @param material The material used on the mesh
  106327. * @returns true if it can be rendered otherwise false
  106328. */
  106329. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106330. /**
  106331. * Implementation specific of rendering the generating effect on the main canvas.
  106332. * @param effect The effect used to render through
  106333. */
  106334. protected _internalRender(effect: Effect): void;
  106335. /**
  106336. * Sets the required values for both the emissive texture and and the main color.
  106337. */
  106338. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106339. /**
  106340. * Returns true if the mesh should render, otherwise false.
  106341. * @param mesh The mesh to render
  106342. * @returns true if it should render otherwise false
  106343. */
  106344. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106345. /**
  106346. * Adds specific effects defines.
  106347. * @param defines The defines to add specifics to.
  106348. */
  106349. protected _addCustomEffectDefines(defines: string[]): void;
  106350. /**
  106351. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106352. * @param mesh The mesh to exclude from the glow layer
  106353. */
  106354. addExcludedMesh(mesh: Mesh): void;
  106355. /**
  106356. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106357. * @param mesh The mesh to remove
  106358. */
  106359. removeExcludedMesh(mesh: Mesh): void;
  106360. /**
  106361. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106362. * @param mesh The mesh to include in the glow layer
  106363. */
  106364. addIncludedOnlyMesh(mesh: Mesh): void;
  106365. /**
  106366. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106367. * @param mesh The mesh to remove
  106368. */
  106369. removeIncludedOnlyMesh(mesh: Mesh): void;
  106370. /**
  106371. * Determine if a given mesh will be used in the glow layer
  106372. * @param mesh The mesh to test
  106373. * @returns true if the mesh will be highlighted by the current glow layer
  106374. */
  106375. hasMesh(mesh: AbstractMesh): boolean;
  106376. /**
  106377. * Free any resources and references associated to a mesh.
  106378. * Internal use
  106379. * @param mesh The mesh to free.
  106380. * @hidden
  106381. */
  106382. _disposeMesh(mesh: Mesh): void;
  106383. /**
  106384. * Gets the class name of the effect layer
  106385. * @returns the string with the class name of the effect layer
  106386. */
  106387. getClassName(): string;
  106388. /**
  106389. * Serializes this glow layer
  106390. * @returns a serialized glow layer object
  106391. */
  106392. serialize(): any;
  106393. /**
  106394. * Creates a Glow Layer from parsed glow layer data
  106395. * @param parsedGlowLayer defines glow layer data
  106396. * @param scene defines the current scene
  106397. * @param rootUrl defines the root URL containing the glow layer information
  106398. * @returns a parsed Glow Layer
  106399. */
  106400. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106401. }
  106402. }
  106403. declare module BABYLON {
  106404. /** @hidden */
  106405. export var glowBlurPostProcessPixelShader: {
  106406. name: string;
  106407. shader: string;
  106408. };
  106409. }
  106410. declare module BABYLON {
  106411. interface AbstractScene {
  106412. /**
  106413. * Return a the first highlight layer of the scene with a given name.
  106414. * @param name The name of the highlight layer to look for.
  106415. * @return The highlight layer if found otherwise null.
  106416. */
  106417. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106418. }
  106419. /**
  106420. * Highlight layer options. This helps customizing the behaviour
  106421. * of the highlight layer.
  106422. */
  106423. export interface IHighlightLayerOptions {
  106424. /**
  106425. * Multiplication factor apply to the canvas size to compute the render target size
  106426. * used to generated the glowing objects (the smaller the faster).
  106427. */
  106428. mainTextureRatio: number;
  106429. /**
  106430. * Enforces a fixed size texture to ensure resize independant blur.
  106431. */
  106432. mainTextureFixedSize?: number;
  106433. /**
  106434. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106435. * of the picture to blur (the smaller the faster).
  106436. */
  106437. blurTextureSizeRatio: number;
  106438. /**
  106439. * How big in texel of the blur texture is the vertical blur.
  106440. */
  106441. blurVerticalSize: number;
  106442. /**
  106443. * How big in texel of the blur texture is the horizontal blur.
  106444. */
  106445. blurHorizontalSize: number;
  106446. /**
  106447. * Alpha blending mode used to apply the blur. Default is combine.
  106448. */
  106449. alphaBlendingMode: number;
  106450. /**
  106451. * The camera attached to the layer.
  106452. */
  106453. camera: Nullable<Camera>;
  106454. /**
  106455. * Should we display highlight as a solid stroke?
  106456. */
  106457. isStroke?: boolean;
  106458. /**
  106459. * The rendering group to draw the layer in.
  106460. */
  106461. renderingGroupId: number;
  106462. }
  106463. /**
  106464. * The highlight layer Helps adding a glow effect around a mesh.
  106465. *
  106466. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106467. * glowy meshes to your scene.
  106468. *
  106469. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106470. */
  106471. export class HighlightLayer extends EffectLayer {
  106472. name: string;
  106473. /**
  106474. * Effect Name of the highlight layer.
  106475. */
  106476. static readonly EffectName: string;
  106477. /**
  106478. * The neutral color used during the preparation of the glow effect.
  106479. * This is black by default as the blend operation is a blend operation.
  106480. */
  106481. static NeutralColor: Color4;
  106482. /**
  106483. * Stencil value used for glowing meshes.
  106484. */
  106485. static GlowingMeshStencilReference: number;
  106486. /**
  106487. * Stencil value used for the other meshes in the scene.
  106488. */
  106489. static NormalMeshStencilReference: number;
  106490. /**
  106491. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106492. */
  106493. innerGlow: boolean;
  106494. /**
  106495. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106496. */
  106497. outerGlow: boolean;
  106498. /**
  106499. * Specifies the horizontal size of the blur.
  106500. */
  106501. /**
  106502. * Gets the horizontal size of the blur.
  106503. */
  106504. blurHorizontalSize: number;
  106505. /**
  106506. * Specifies the vertical size of the blur.
  106507. */
  106508. /**
  106509. * Gets the vertical size of the blur.
  106510. */
  106511. blurVerticalSize: number;
  106512. /**
  106513. * An event triggered when the highlight layer is being blurred.
  106514. */
  106515. onBeforeBlurObservable: Observable<HighlightLayer>;
  106516. /**
  106517. * An event triggered when the highlight layer has been blurred.
  106518. */
  106519. onAfterBlurObservable: Observable<HighlightLayer>;
  106520. private _instanceGlowingMeshStencilReference;
  106521. private _options;
  106522. private _downSamplePostprocess;
  106523. private _horizontalBlurPostprocess;
  106524. private _verticalBlurPostprocess;
  106525. private _blurTexture;
  106526. private _meshes;
  106527. private _excludedMeshes;
  106528. /**
  106529. * Instantiates a new highlight Layer and references it to the scene..
  106530. * @param name The name of the layer
  106531. * @param scene The scene to use the layer in
  106532. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106533. */
  106534. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106535. /**
  106536. * Get the effect name of the layer.
  106537. * @return The effect name
  106538. */
  106539. getEffectName(): string;
  106540. /**
  106541. * Create the merge effect. This is the shader use to blit the information back
  106542. * to the main canvas at the end of the scene rendering.
  106543. */
  106544. protected _createMergeEffect(): Effect;
  106545. /**
  106546. * Creates the render target textures and post processes used in the highlight layer.
  106547. */
  106548. protected _createTextureAndPostProcesses(): void;
  106549. /**
  106550. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106551. */
  106552. needStencil(): boolean;
  106553. /**
  106554. * Checks for the readiness of the element composing the layer.
  106555. * @param subMesh the mesh to check for
  106556. * @param useInstances specify wether or not to use instances to render the mesh
  106557. * @param emissiveTexture the associated emissive texture used to generate the glow
  106558. * @return true if ready otherwise, false
  106559. */
  106560. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106561. /**
  106562. * Implementation specific of rendering the generating effect on the main canvas.
  106563. * @param effect The effect used to render through
  106564. */
  106565. protected _internalRender(effect: Effect): void;
  106566. /**
  106567. * Returns true if the layer contains information to display, otherwise false.
  106568. */
  106569. shouldRender(): boolean;
  106570. /**
  106571. * Returns true if the mesh should render, otherwise false.
  106572. * @param mesh The mesh to render
  106573. * @returns true if it should render otherwise false
  106574. */
  106575. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106576. /**
  106577. * Sets the required values for both the emissive texture and and the main color.
  106578. */
  106579. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106580. /**
  106581. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106582. * @param mesh The mesh to exclude from the highlight layer
  106583. */
  106584. addExcludedMesh(mesh: Mesh): void;
  106585. /**
  106586. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106587. * @param mesh The mesh to highlight
  106588. */
  106589. removeExcludedMesh(mesh: Mesh): void;
  106590. /**
  106591. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106592. * @param mesh mesh to test
  106593. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106594. */
  106595. hasMesh(mesh: AbstractMesh): boolean;
  106596. /**
  106597. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106598. * @param mesh The mesh to highlight
  106599. * @param color The color of the highlight
  106600. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106601. */
  106602. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106603. /**
  106604. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106605. * @param mesh The mesh to highlight
  106606. */
  106607. removeMesh(mesh: Mesh): void;
  106608. /**
  106609. * Force the stencil to the normal expected value for none glowing parts
  106610. */
  106611. private _defaultStencilReference;
  106612. /**
  106613. * Free any resources and references associated to a mesh.
  106614. * Internal use
  106615. * @param mesh The mesh to free.
  106616. * @hidden
  106617. */
  106618. _disposeMesh(mesh: Mesh): void;
  106619. /**
  106620. * Dispose the highlight layer and free resources.
  106621. */
  106622. dispose(): void;
  106623. /**
  106624. * Gets the class name of the effect layer
  106625. * @returns the string with the class name of the effect layer
  106626. */
  106627. getClassName(): string;
  106628. /**
  106629. * Serializes this Highlight layer
  106630. * @returns a serialized Highlight layer object
  106631. */
  106632. serialize(): any;
  106633. /**
  106634. * Creates a Highlight layer from parsed Highlight layer data
  106635. * @param parsedHightlightLayer defines the Highlight layer data
  106636. * @param scene defines the current scene
  106637. * @param rootUrl defines the root URL containing the Highlight layer information
  106638. * @returns a parsed Highlight layer
  106639. */
  106640. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106641. }
  106642. }
  106643. declare module BABYLON {
  106644. /** @hidden */
  106645. export var lensFlarePixelShader: {
  106646. name: string;
  106647. shader: string;
  106648. };
  106649. }
  106650. declare module BABYLON {
  106651. /** @hidden */
  106652. export var lensFlareVertexShader: {
  106653. name: string;
  106654. shader: string;
  106655. };
  106656. }
  106657. declare module BABYLON {
  106658. /**
  106659. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106660. * It is usually composed of several `lensFlare`.
  106661. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106662. */
  106663. export class LensFlareSystem {
  106664. /**
  106665. * Define the name of the lens flare system
  106666. */
  106667. name: string;
  106668. /**
  106669. * List of lens flares used in this system.
  106670. */
  106671. lensFlares: LensFlare[];
  106672. /**
  106673. * Define a limit from the border the lens flare can be visible.
  106674. */
  106675. borderLimit: number;
  106676. /**
  106677. * Define a viewport border we do not want to see the lens flare in.
  106678. */
  106679. viewportBorder: number;
  106680. /**
  106681. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106682. */
  106683. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106684. /**
  106685. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106686. */
  106687. layerMask: number;
  106688. /**
  106689. * Define the id of the lens flare system in the scene.
  106690. * (equal to name by default)
  106691. */
  106692. id: string;
  106693. private _scene;
  106694. private _emitter;
  106695. private _vertexBuffers;
  106696. private _indexBuffer;
  106697. private _effect;
  106698. private _positionX;
  106699. private _positionY;
  106700. private _isEnabled;
  106701. /** @hidden */
  106702. static _SceneComponentInitialization: (scene: Scene) => void;
  106703. /**
  106704. * Instantiates a lens flare system.
  106705. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106706. * It is usually composed of several `lensFlare`.
  106707. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106708. * @param name Define the name of the lens flare system in the scene
  106709. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106710. * @param scene Define the scene the lens flare system belongs to
  106711. */
  106712. constructor(
  106713. /**
  106714. * Define the name of the lens flare system
  106715. */
  106716. name: string, emitter: any, scene: Scene);
  106717. /**
  106718. * Define if the lens flare system is enabled.
  106719. */
  106720. isEnabled: boolean;
  106721. /**
  106722. * Get the scene the effects belongs to.
  106723. * @returns the scene holding the lens flare system
  106724. */
  106725. getScene(): Scene;
  106726. /**
  106727. * Get 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. * @returns the emitter of the lens flare system
  106730. */
  106731. getEmitter(): any;
  106732. /**
  106733. * Set the emitter of the lens flare system.
  106734. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106735. * @param newEmitter Define the new emitter of the system
  106736. */
  106737. setEmitter(newEmitter: any): void;
  106738. /**
  106739. * Get the lens flare system emitter position.
  106740. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106741. * @returns the position
  106742. */
  106743. getEmitterPosition(): Vector3;
  106744. /**
  106745. * @hidden
  106746. */
  106747. computeEffectivePosition(globalViewport: Viewport): boolean;
  106748. /** @hidden */
  106749. _isVisible(): boolean;
  106750. /**
  106751. * @hidden
  106752. */
  106753. render(): boolean;
  106754. /**
  106755. * Dispose and release the lens flare with its associated resources.
  106756. */
  106757. dispose(): void;
  106758. /**
  106759. * Parse a lens flare system from a JSON repressentation
  106760. * @param parsedLensFlareSystem Define the JSON to parse
  106761. * @param scene Define the scene the parsed system should be instantiated in
  106762. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106763. * @returns the parsed system
  106764. */
  106765. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106766. /**
  106767. * Serialize the current Lens Flare System into a JSON representation.
  106768. * @returns the serialized JSON
  106769. */
  106770. serialize(): any;
  106771. }
  106772. }
  106773. declare module BABYLON {
  106774. /**
  106775. * This represents one of the lens effect in a `lensFlareSystem`.
  106776. * It controls one of the indiviual texture used in the effect.
  106777. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106778. */
  106779. export class LensFlare {
  106780. /**
  106781. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106782. */
  106783. size: number;
  106784. /**
  106785. * 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.
  106786. */
  106787. position: number;
  106788. /**
  106789. * Define the lens color.
  106790. */
  106791. color: Color3;
  106792. /**
  106793. * Define the lens texture.
  106794. */
  106795. texture: Nullable<Texture>;
  106796. /**
  106797. * Define the alpha mode to render this particular lens.
  106798. */
  106799. alphaMode: number;
  106800. private _system;
  106801. /**
  106802. * Creates a new Lens Flare.
  106803. * This represents one of the lens effect in a `lensFlareSystem`.
  106804. * It controls one of the indiviual texture used in the effect.
  106805. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106806. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  106807. * @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.
  106808. * @param color Define the lens color
  106809. * @param imgUrl Define the lens texture url
  106810. * @param system Define the `lensFlareSystem` this flare is part of
  106811. * @returns The newly created Lens Flare
  106812. */
  106813. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  106814. /**
  106815. * Instantiates a new Lens Flare.
  106816. * This represents one of the lens effect in a `lensFlareSystem`.
  106817. * It controls one of the indiviual texture used in the effect.
  106818. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106819. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  106820. * @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.
  106821. * @param color Define the lens color
  106822. * @param imgUrl Define the lens texture url
  106823. * @param system Define the `lensFlareSystem` this flare is part of
  106824. */
  106825. constructor(
  106826. /**
  106827. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106828. */
  106829. size: number,
  106830. /**
  106831. * 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.
  106832. */
  106833. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  106834. /**
  106835. * Dispose and release the lens flare with its associated resources.
  106836. */
  106837. dispose(): void;
  106838. }
  106839. }
  106840. declare module BABYLON {
  106841. interface AbstractScene {
  106842. /**
  106843. * The list of lens flare system added to the scene
  106844. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106845. */
  106846. lensFlareSystems: Array<LensFlareSystem>;
  106847. /**
  106848. * Removes the given lens flare system from this scene.
  106849. * @param toRemove The lens flare system to remove
  106850. * @returns The index of the removed lens flare system
  106851. */
  106852. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  106853. /**
  106854. * Adds the given lens flare system to this scene
  106855. * @param newLensFlareSystem The lens flare system to add
  106856. */
  106857. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  106858. /**
  106859. * Gets a lens flare system using its name
  106860. * @param name defines the name to look for
  106861. * @returns the lens flare system or null if not found
  106862. */
  106863. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  106864. /**
  106865. * Gets a lens flare system using its id
  106866. * @param id defines the id to look for
  106867. * @returns the lens flare system or null if not found
  106868. */
  106869. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  106870. }
  106871. /**
  106872. * Defines the lens flare scene component responsible to manage any lens flares
  106873. * in a given scene.
  106874. */
  106875. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  106876. /**
  106877. * The component name helpfull to identify the component in the list of scene components.
  106878. */
  106879. readonly name: string;
  106880. /**
  106881. * The scene the component belongs to.
  106882. */
  106883. scene: Scene;
  106884. /**
  106885. * Creates a new instance of the component for the given scene
  106886. * @param scene Defines the scene to register the component in
  106887. */
  106888. constructor(scene: Scene);
  106889. /**
  106890. * Registers the component in a given scene
  106891. */
  106892. register(): void;
  106893. /**
  106894. * Rebuilds the elements related to this component in case of
  106895. * context lost for instance.
  106896. */
  106897. rebuild(): void;
  106898. /**
  106899. * Adds all the element from the container to the scene
  106900. * @param container the container holding the elements
  106901. */
  106902. addFromContainer(container: AbstractScene): void;
  106903. /**
  106904. * Removes all the elements in the container from the scene
  106905. * @param container contains the elements to remove
  106906. * @param dispose if the removed element should be disposed (default: false)
  106907. */
  106908. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106909. /**
  106910. * Serializes the component data to the specified json object
  106911. * @param serializationObject The object to serialize to
  106912. */
  106913. serialize(serializationObject: any): void;
  106914. /**
  106915. * Disposes the component and the associated ressources.
  106916. */
  106917. dispose(): void;
  106918. private _draw;
  106919. }
  106920. }
  106921. declare module BABYLON {
  106922. /**
  106923. * Defines the shadow generator component responsible to manage any shadow generators
  106924. * in a given scene.
  106925. */
  106926. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  106927. /**
  106928. * The component name helpfull to identify the component in the list of scene components.
  106929. */
  106930. readonly name: string;
  106931. /**
  106932. * The scene the component belongs to.
  106933. */
  106934. scene: Scene;
  106935. /**
  106936. * Creates a new instance of the component for the given scene
  106937. * @param scene Defines the scene to register the component in
  106938. */
  106939. constructor(scene: Scene);
  106940. /**
  106941. * Registers the component in a given scene
  106942. */
  106943. register(): void;
  106944. /**
  106945. * Rebuilds the elements related to this component in case of
  106946. * context lost for instance.
  106947. */
  106948. rebuild(): void;
  106949. /**
  106950. * Serializes the component data to the specified json object
  106951. * @param serializationObject The object to serialize to
  106952. */
  106953. serialize(serializationObject: any): void;
  106954. /**
  106955. * Adds all the element from the container to the scene
  106956. * @param container the container holding the elements
  106957. */
  106958. addFromContainer(container: AbstractScene): void;
  106959. /**
  106960. * Removes all the elements in the container from the scene
  106961. * @param container contains the elements to remove
  106962. * @param dispose if the removed element should be disposed (default: false)
  106963. */
  106964. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106965. /**
  106966. * Rebuilds the elements related to this component in case of
  106967. * context lost for instance.
  106968. */
  106969. dispose(): void;
  106970. private _gatherRenderTargets;
  106971. }
  106972. }
  106973. declare module BABYLON {
  106974. /**
  106975. * A point light is a light defined by an unique point in world space.
  106976. * The light is emitted in every direction from this point.
  106977. * A good example of a point light is a standard light bulb.
  106978. * Documentation: https://doc.babylonjs.com/babylon101/lights
  106979. */
  106980. export class PointLight extends ShadowLight {
  106981. private _shadowAngle;
  106982. /**
  106983. * Getter: 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. /**
  106989. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106990. * This specifies what angle the shadow will use to be created.
  106991. *
  106992. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  106993. */
  106994. shadowAngle: number;
  106995. /**
  106996. * Gets the direction if it has been set.
  106997. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  106998. */
  106999. /**
  107000. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107001. */
  107002. direction: Vector3;
  107003. /**
  107004. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107005. * A PointLight emits the light in every direction.
  107006. * It can cast shadows.
  107007. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107008. * ```javascript
  107009. * var pointLight = new PointLight("pl", camera.position, scene);
  107010. * ```
  107011. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107012. * @param name The light friendly name
  107013. * @param position The position of the point light in the scene
  107014. * @param scene The scene the lights belongs to
  107015. */
  107016. constructor(name: string, position: Vector3, scene: Scene);
  107017. /**
  107018. * Returns the string "PointLight"
  107019. * @returns the class name
  107020. */
  107021. getClassName(): string;
  107022. /**
  107023. * Returns the integer 0.
  107024. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107025. */
  107026. getTypeID(): number;
  107027. /**
  107028. * Specifies wether or not the shadowmap should be a cube texture.
  107029. * @returns true if the shadowmap needs to be a cube texture.
  107030. */
  107031. needCube(): boolean;
  107032. /**
  107033. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107034. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107035. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107036. */
  107037. getShadowDirection(faceIndex?: number): Vector3;
  107038. /**
  107039. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107040. * - fov = PI / 2
  107041. * - aspect ratio : 1.0
  107042. * - z-near and far equal to the active camera minZ and maxZ.
  107043. * Returns the PointLight.
  107044. */
  107045. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107046. protected _buildUniformLayout(): void;
  107047. /**
  107048. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107049. * @param effect The effect to update
  107050. * @param lightIndex The index of the light in the effect to update
  107051. * @returns The point light
  107052. */
  107053. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107054. /**
  107055. * Prepares the list of defines specific to the light type.
  107056. * @param defines the list of defines
  107057. * @param lightIndex defines the index of the light for the effect
  107058. */
  107059. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107060. }
  107061. }
  107062. declare module BABYLON {
  107063. /**
  107064. * Header information of HDR texture files.
  107065. */
  107066. export interface HDRInfo {
  107067. /**
  107068. * The height of the texture in pixels.
  107069. */
  107070. height: number;
  107071. /**
  107072. * The width of the texture in pixels.
  107073. */
  107074. width: number;
  107075. /**
  107076. * The index of the beginning of the data in the binary file.
  107077. */
  107078. dataPosition: number;
  107079. }
  107080. /**
  107081. * This groups tools to convert HDR texture to native colors array.
  107082. */
  107083. export class HDRTools {
  107084. private static Ldexp;
  107085. private static Rgbe2float;
  107086. private static readStringLine;
  107087. /**
  107088. * Reads header information from an RGBE texture stored in a native array.
  107089. * More information on this format are available here:
  107090. * https://en.wikipedia.org/wiki/RGBE_image_format
  107091. *
  107092. * @param uint8array The binary file stored in native array.
  107093. * @return The header information.
  107094. */
  107095. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107096. /**
  107097. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107098. * This RGBE texture needs to store the information as a panorama.
  107099. *
  107100. * More information on this format are available here:
  107101. * https://en.wikipedia.org/wiki/RGBE_image_format
  107102. *
  107103. * @param buffer The binary file stored in an array buffer.
  107104. * @param size The expected size of the extracted cubemap.
  107105. * @return The Cube Map information.
  107106. */
  107107. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107108. /**
  107109. * Returns the pixels data extracted from an RGBE texture.
  107110. * This pixels will be stored left to right up to down in the R G B order in one array.
  107111. *
  107112. * More information on this format are available here:
  107113. * https://en.wikipedia.org/wiki/RGBE_image_format
  107114. *
  107115. * @param uint8array The binary file stored in an array buffer.
  107116. * @param hdrInfo The header information of the file.
  107117. * @return The pixels data in RGB right to left up to down order.
  107118. */
  107119. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107120. private static RGBE_ReadPixels_RLE;
  107121. }
  107122. }
  107123. declare module BABYLON {
  107124. /**
  107125. * This represents a texture coming from an HDR input.
  107126. *
  107127. * The only supported format is currently panorama picture stored in RGBE format.
  107128. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107129. */
  107130. export class HDRCubeTexture extends BaseTexture {
  107131. private static _facesMapping;
  107132. private _generateHarmonics;
  107133. private _noMipmap;
  107134. private _textureMatrix;
  107135. private _size;
  107136. private _onLoad;
  107137. private _onError;
  107138. /**
  107139. * The texture URL.
  107140. */
  107141. url: string;
  107142. /**
  107143. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107144. */
  107145. coordinatesMode: number;
  107146. protected _isBlocking: boolean;
  107147. /**
  107148. * Sets wether or not the texture is blocking during loading.
  107149. */
  107150. /**
  107151. * Gets wether or not the texture is blocking during loading.
  107152. */
  107153. isBlocking: boolean;
  107154. protected _rotationY: number;
  107155. /**
  107156. * Sets texture matrix rotation angle around Y axis in radians.
  107157. */
  107158. /**
  107159. * Gets texture matrix rotation angle around Y axis radians.
  107160. */
  107161. rotationY: number;
  107162. /**
  107163. * Gets or sets the center of the bounding box associated with the cube texture
  107164. * It must define where the camera used to render the texture was set
  107165. */
  107166. boundingBoxPosition: Vector3;
  107167. private _boundingBoxSize;
  107168. /**
  107169. * Gets or sets the size of the bounding box associated with the cube texture
  107170. * When defined, the cubemap will switch to local mode
  107171. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107172. * @example https://www.babylonjs-playground.com/#RNASML
  107173. */
  107174. boundingBoxSize: Vector3;
  107175. /**
  107176. * Instantiates an HDRTexture from the following parameters.
  107177. *
  107178. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107179. * @param scene The scene the texture will be used in
  107180. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107181. * @param noMipmap Forces to not generate the mipmap if true
  107182. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107183. * @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)
  107184. * @param reserved Reserved flag for internal use.
  107185. */
  107186. 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>);
  107187. /**
  107188. * Get the current class name of the texture useful for serialization or dynamic coding.
  107189. * @returns "HDRCubeTexture"
  107190. */
  107191. getClassName(): string;
  107192. /**
  107193. * Occurs when the file is raw .hdr file.
  107194. */
  107195. private loadTexture;
  107196. clone(): HDRCubeTexture;
  107197. delayLoad(): void;
  107198. /**
  107199. * Get the texture reflection matrix used to rotate/transform the reflection.
  107200. * @returns the reflection matrix
  107201. */
  107202. getReflectionTextureMatrix(): Matrix;
  107203. /**
  107204. * Set the texture reflection matrix used to rotate/transform the reflection.
  107205. * @param value Define the reflection matrix to set
  107206. */
  107207. setReflectionTextureMatrix(value: Matrix): void;
  107208. /**
  107209. * Parses a JSON representation of an HDR Texture in order to create the texture
  107210. * @param parsedTexture Define the JSON representation
  107211. * @param scene Define the scene the texture should be created in
  107212. * @param rootUrl Define the root url in case we need to load relative dependencies
  107213. * @returns the newly created texture after parsing
  107214. */
  107215. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107216. serialize(): any;
  107217. }
  107218. }
  107219. declare module BABYLON {
  107220. /**
  107221. * Class used to control physics engine
  107222. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107223. */
  107224. export class PhysicsEngine implements IPhysicsEngine {
  107225. private _physicsPlugin;
  107226. /**
  107227. * Global value used to control the smallest number supported by the simulation
  107228. */
  107229. static Epsilon: number;
  107230. private _impostors;
  107231. private _joints;
  107232. /**
  107233. * Gets the gravity vector used by the simulation
  107234. */
  107235. gravity: Vector3;
  107236. /**
  107237. * Factory used to create the default physics plugin.
  107238. * @returns The default physics plugin
  107239. */
  107240. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107241. /**
  107242. * Creates a new Physics Engine
  107243. * @param gravity defines the gravity vector used by the simulation
  107244. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107245. */
  107246. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107247. /**
  107248. * Sets the gravity vector used by the simulation
  107249. * @param gravity defines the gravity vector to use
  107250. */
  107251. setGravity(gravity: Vector3): void;
  107252. /**
  107253. * Set the time step of the physics engine.
  107254. * Default is 1/60.
  107255. * To slow it down, enter 1/600 for example.
  107256. * To speed it up, 1/30
  107257. * @param newTimeStep defines the new timestep to apply to this world.
  107258. */
  107259. setTimeStep(newTimeStep?: number): void;
  107260. /**
  107261. * Get the time step of the physics engine.
  107262. * @returns the current time step
  107263. */
  107264. getTimeStep(): number;
  107265. /**
  107266. * Release all resources
  107267. */
  107268. dispose(): void;
  107269. /**
  107270. * Gets the name of the current physics plugin
  107271. * @returns the name of the plugin
  107272. */
  107273. getPhysicsPluginName(): string;
  107274. /**
  107275. * Adding a new impostor for the impostor tracking.
  107276. * This will be done by the impostor itself.
  107277. * @param impostor the impostor to add
  107278. */
  107279. addImpostor(impostor: PhysicsImpostor): void;
  107280. /**
  107281. * Remove an impostor from the engine.
  107282. * This impostor and its mesh will not longer be updated by the physics engine.
  107283. * @param impostor the impostor to remove
  107284. */
  107285. removeImpostor(impostor: PhysicsImpostor): void;
  107286. /**
  107287. * Add a joint to the physics engine
  107288. * @param mainImpostor defines the main impostor to which the joint is added.
  107289. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107290. * @param joint defines the joint that will connect both impostors.
  107291. */
  107292. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107293. /**
  107294. * Removes a joint from the simulation
  107295. * @param mainImpostor defines the impostor used with the joint
  107296. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107297. * @param joint defines the joint to remove
  107298. */
  107299. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107300. /**
  107301. * Called by the scene. No need to call it.
  107302. * @param delta defines the timespam between frames
  107303. */
  107304. _step(delta: number): void;
  107305. /**
  107306. * Gets the current plugin used to run the simulation
  107307. * @returns current plugin
  107308. */
  107309. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107310. /**
  107311. * Gets the list of physic impostors
  107312. * @returns an array of PhysicsImpostor
  107313. */
  107314. getImpostors(): Array<PhysicsImpostor>;
  107315. /**
  107316. * Gets the impostor for a physics enabled object
  107317. * @param object defines the object impersonated by the impostor
  107318. * @returns the PhysicsImpostor or null if not found
  107319. */
  107320. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107321. /**
  107322. * Gets the impostor for a physics body object
  107323. * @param body defines physics body used by the impostor
  107324. * @returns the PhysicsImpostor or null if not found
  107325. */
  107326. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107327. /**
  107328. * Does a raycast in the physics world
  107329. * @param from when should the ray start?
  107330. * @param to when should the ray end?
  107331. * @returns PhysicsRaycastResult
  107332. */
  107333. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107334. }
  107335. }
  107336. declare module BABYLON {
  107337. /** @hidden */
  107338. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107339. private _useDeltaForWorldStep;
  107340. world: any;
  107341. name: string;
  107342. private _physicsMaterials;
  107343. private _fixedTimeStep;
  107344. private _cannonRaycastResult;
  107345. private _raycastResult;
  107346. private _removeAfterStep;
  107347. BJSCANNON: any;
  107348. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107349. setGravity(gravity: Vector3): void;
  107350. setTimeStep(timeStep: number): void;
  107351. getTimeStep(): number;
  107352. executeStep(delta: number): void;
  107353. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107354. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107355. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107356. private _processChildMeshes;
  107357. removePhysicsBody(impostor: PhysicsImpostor): void;
  107358. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107359. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107360. private _addMaterial;
  107361. private _checkWithEpsilon;
  107362. private _createShape;
  107363. private _createHeightmap;
  107364. private _minus90X;
  107365. private _plus90X;
  107366. private _tmpPosition;
  107367. private _tmpDeltaPosition;
  107368. private _tmpUnityRotation;
  107369. private _updatePhysicsBodyTransformation;
  107370. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107371. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107372. isSupported(): boolean;
  107373. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107374. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107375. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107376. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107377. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107378. getBodyMass(impostor: PhysicsImpostor): number;
  107379. getBodyFriction(impostor: PhysicsImpostor): number;
  107380. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107381. getBodyRestitution(impostor: PhysicsImpostor): number;
  107382. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107383. sleepBody(impostor: PhysicsImpostor): void;
  107384. wakeUpBody(impostor: PhysicsImpostor): void;
  107385. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107386. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107387. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107388. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107389. getRadius(impostor: PhysicsImpostor): number;
  107390. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107391. dispose(): void;
  107392. private _extendNamespace;
  107393. /**
  107394. * Does a raycast in the physics world
  107395. * @param from when should the ray start?
  107396. * @param to when should the ray end?
  107397. * @returns PhysicsRaycastResult
  107398. */
  107399. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107400. }
  107401. }
  107402. declare module BABYLON {
  107403. /** @hidden */
  107404. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107405. world: any;
  107406. name: string;
  107407. BJSOIMO: any;
  107408. private _raycastResult;
  107409. constructor(iterations?: number, oimoInjection?: any);
  107410. setGravity(gravity: Vector3): void;
  107411. setTimeStep(timeStep: number): void;
  107412. getTimeStep(): number;
  107413. private _tmpImpostorsArray;
  107414. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107415. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107416. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107417. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107418. private _tmpPositionVector;
  107419. removePhysicsBody(impostor: PhysicsImpostor): void;
  107420. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107421. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107422. isSupported(): boolean;
  107423. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107424. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107425. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107426. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107427. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107428. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107429. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107430. getBodyMass(impostor: PhysicsImpostor): number;
  107431. getBodyFriction(impostor: PhysicsImpostor): number;
  107432. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107433. getBodyRestitution(impostor: PhysicsImpostor): number;
  107434. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107435. sleepBody(impostor: PhysicsImpostor): void;
  107436. wakeUpBody(impostor: PhysicsImpostor): void;
  107437. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107438. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107439. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107440. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107441. getRadius(impostor: PhysicsImpostor): number;
  107442. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107443. dispose(): void;
  107444. /**
  107445. * Does a raycast in the physics world
  107446. * @param from when should the ray start?
  107447. * @param to when should the ray end?
  107448. * @returns PhysicsRaycastResult
  107449. */
  107450. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107451. }
  107452. }
  107453. declare module BABYLON {
  107454. /**
  107455. * Class containing static functions to help procedurally build meshes
  107456. */
  107457. export class RibbonBuilder {
  107458. /**
  107459. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107460. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107461. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107462. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107463. * * 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
  107464. * * 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
  107465. * * 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
  107466. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107467. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107468. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107469. * * 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
  107470. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107471. * * 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
  107472. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107473. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107474. * @param name defines the name of the mesh
  107475. * @param options defines the options used to create the mesh
  107476. * @param scene defines the hosting scene
  107477. * @returns the ribbon mesh
  107478. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107479. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107480. */
  107481. static CreateRibbon(name: string, options: {
  107482. pathArray: Vector3[][];
  107483. closeArray?: boolean;
  107484. closePath?: boolean;
  107485. offset?: number;
  107486. updatable?: boolean;
  107487. sideOrientation?: number;
  107488. frontUVs?: Vector4;
  107489. backUVs?: Vector4;
  107490. instance?: Mesh;
  107491. invertUV?: boolean;
  107492. uvs?: Vector2[];
  107493. colors?: Color4[];
  107494. }, scene?: Nullable<Scene>): Mesh;
  107495. }
  107496. }
  107497. declare module BABYLON {
  107498. /**
  107499. * Class containing static functions to help procedurally build meshes
  107500. */
  107501. export class ShapeBuilder {
  107502. /**
  107503. * 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.
  107504. * * 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.
  107505. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107506. * * 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.
  107507. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107508. * * 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
  107509. * * 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
  107510. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107513. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107515. * @param name defines the name of the mesh
  107516. * @param options defines the options used to create the mesh
  107517. * @param scene defines the hosting scene
  107518. * @returns the extruded shape mesh
  107519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107521. */
  107522. static ExtrudeShape(name: string, options: {
  107523. shape: Vector3[];
  107524. path: Vector3[];
  107525. scale?: number;
  107526. rotation?: number;
  107527. cap?: number;
  107528. updatable?: boolean;
  107529. sideOrientation?: number;
  107530. frontUVs?: Vector4;
  107531. backUVs?: Vector4;
  107532. instance?: Mesh;
  107533. invertUV?: boolean;
  107534. }, scene?: Nullable<Scene>): Mesh;
  107535. /**
  107536. * Creates an custom extruded shape mesh.
  107537. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107538. * * 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.
  107539. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107540. * * 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
  107541. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107542. * * 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
  107543. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107544. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107545. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107546. * * 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
  107547. * * 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
  107548. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107553. * @param name defines the name of the mesh
  107554. * @param options defines the options used to create the mesh
  107555. * @param scene defines the hosting scene
  107556. * @returns the custom extruded shape mesh
  107557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107560. */
  107561. static ExtrudeShapeCustom(name: string, options: {
  107562. shape: Vector3[];
  107563. path: Vector3[];
  107564. scaleFunction?: any;
  107565. rotationFunction?: any;
  107566. ribbonCloseArray?: boolean;
  107567. ribbonClosePath?: boolean;
  107568. cap?: number;
  107569. updatable?: boolean;
  107570. sideOrientation?: number;
  107571. frontUVs?: Vector4;
  107572. backUVs?: Vector4;
  107573. instance?: Mesh;
  107574. invertUV?: boolean;
  107575. }, scene?: Nullable<Scene>): Mesh;
  107576. private static _ExtrudeShapeGeneric;
  107577. }
  107578. }
  107579. declare module BABYLON {
  107580. /**
  107581. * AmmoJS Physics plugin
  107582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107583. * @see https://github.com/kripken/ammo.js/
  107584. */
  107585. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107586. private _useDeltaForWorldStep;
  107587. /**
  107588. * Reference to the Ammo library
  107589. */
  107590. bjsAMMO: any;
  107591. /**
  107592. * Created ammoJS world which physics bodies are added to
  107593. */
  107594. world: any;
  107595. /**
  107596. * Name of the plugin
  107597. */
  107598. name: string;
  107599. private _timeStep;
  107600. private _fixedTimeStep;
  107601. private _maxSteps;
  107602. private _tmpQuaternion;
  107603. private _tmpAmmoTransform;
  107604. private _tmpAmmoQuaternion;
  107605. private _tmpAmmoConcreteContactResultCallback;
  107606. private _collisionConfiguration;
  107607. private _dispatcher;
  107608. private _overlappingPairCache;
  107609. private _solver;
  107610. private _softBodySolver;
  107611. private _tmpAmmoVectorA;
  107612. private _tmpAmmoVectorB;
  107613. private _tmpAmmoVectorC;
  107614. private _tmpAmmoVectorD;
  107615. private _tmpContactCallbackResult;
  107616. private _tmpAmmoVectorRCA;
  107617. private _tmpAmmoVectorRCB;
  107618. private _raycastResult;
  107619. private static readonly DISABLE_COLLISION_FLAG;
  107620. private static readonly KINEMATIC_FLAG;
  107621. private static readonly DISABLE_DEACTIVATION_FLAG;
  107622. /**
  107623. * Initializes the ammoJS plugin
  107624. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107625. * @param ammoInjection can be used to inject your own ammo reference
  107626. */
  107627. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107628. /**
  107629. * Sets the gravity of the physics world (m/(s^2))
  107630. * @param gravity Gravity to set
  107631. */
  107632. setGravity(gravity: Vector3): void;
  107633. /**
  107634. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107635. * @param timeStep timestep to use in seconds
  107636. */
  107637. setTimeStep(timeStep: number): void;
  107638. /**
  107639. * 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)
  107640. * @param fixedTimeStep fixedTimeStep to use in seconds
  107641. */
  107642. setFixedTimeStep(fixedTimeStep: number): void;
  107643. /**
  107644. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107645. * @param maxSteps the maximum number of steps by the physics engine per frame
  107646. */
  107647. setMaxSteps(maxSteps: number): void;
  107648. /**
  107649. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107650. * @returns the current timestep in seconds
  107651. */
  107652. getTimeStep(): number;
  107653. private _isImpostorInContact;
  107654. private _isImpostorPairInContact;
  107655. private _stepSimulation;
  107656. /**
  107657. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107658. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107659. * After the step the babylon meshes are set to the position of the physics imposters
  107660. * @param delta amount of time to step forward
  107661. * @param impostors array of imposters to update before/after the step
  107662. */
  107663. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107664. /**
  107665. * Update babylon mesh to match physics world object
  107666. * @param impostor imposter to match
  107667. */
  107668. private _afterSoftStep;
  107669. /**
  107670. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107671. * @param impostor imposter to match
  107672. */
  107673. private _ropeStep;
  107674. /**
  107675. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107676. * @param impostor imposter to match
  107677. */
  107678. private _softbodyOrClothStep;
  107679. private _tmpVector;
  107680. private _tmpMatrix;
  107681. /**
  107682. * Applies an impulse on the imposter
  107683. * @param impostor imposter to apply impulse to
  107684. * @param force amount of force to be applied to the imposter
  107685. * @param contactPoint the location to apply the impulse on the imposter
  107686. */
  107687. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107688. /**
  107689. * Applies a force on the imposter
  107690. * @param impostor imposter to apply force
  107691. * @param force amount of force to be applied to the imposter
  107692. * @param contactPoint the location to apply the force on the imposter
  107693. */
  107694. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107695. /**
  107696. * Creates a physics body using the plugin
  107697. * @param impostor the imposter to create the physics body on
  107698. */
  107699. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107700. /**
  107701. * Removes the physics body from the imposter and disposes of the body's memory
  107702. * @param impostor imposter to remove the physics body from
  107703. */
  107704. removePhysicsBody(impostor: PhysicsImpostor): void;
  107705. /**
  107706. * Generates a joint
  107707. * @param impostorJoint the imposter joint to create the joint with
  107708. */
  107709. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107710. /**
  107711. * Removes a joint
  107712. * @param impostorJoint the imposter joint to remove the joint from
  107713. */
  107714. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107715. private _addMeshVerts;
  107716. /**
  107717. * Initialise the soft body vertices to match its object's (mesh) vertices
  107718. * Softbody vertices (nodes) are in world space and to match this
  107719. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107720. * @param impostor to create the softbody for
  107721. */
  107722. private _softVertexData;
  107723. /**
  107724. * Create an impostor's soft body
  107725. * @param impostor to create the softbody for
  107726. */
  107727. private _createSoftbody;
  107728. /**
  107729. * Create cloth for an impostor
  107730. * @param impostor to create the softbody for
  107731. */
  107732. private _createCloth;
  107733. /**
  107734. * Create rope for an impostor
  107735. * @param impostor to create the softbody for
  107736. */
  107737. private _createRope;
  107738. private _addHullVerts;
  107739. private _createShape;
  107740. /**
  107741. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107742. * @param impostor imposter containing the physics body and babylon object
  107743. */
  107744. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107745. /**
  107746. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107747. * @param impostor imposter containing the physics body and babylon object
  107748. * @param newPosition new position
  107749. * @param newRotation new rotation
  107750. */
  107751. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107752. /**
  107753. * If this plugin is supported
  107754. * @returns true if its supported
  107755. */
  107756. isSupported(): boolean;
  107757. /**
  107758. * Sets the linear velocity of the physics body
  107759. * @param impostor imposter to set the velocity on
  107760. * @param velocity velocity to set
  107761. */
  107762. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107763. /**
  107764. * Sets the angular velocity of the physics body
  107765. * @param impostor imposter to set the velocity on
  107766. * @param velocity velocity to set
  107767. */
  107768. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107769. /**
  107770. * gets the linear velocity
  107771. * @param impostor imposter to get linear velocity from
  107772. * @returns linear velocity
  107773. */
  107774. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107775. /**
  107776. * gets the angular velocity
  107777. * @param impostor imposter to get angular velocity from
  107778. * @returns angular velocity
  107779. */
  107780. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107781. /**
  107782. * Sets the mass of physics body
  107783. * @param impostor imposter to set the mass on
  107784. * @param mass mass to set
  107785. */
  107786. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107787. /**
  107788. * Gets the mass of the physics body
  107789. * @param impostor imposter to get the mass from
  107790. * @returns mass
  107791. */
  107792. getBodyMass(impostor: PhysicsImpostor): number;
  107793. /**
  107794. * Gets friction of the impostor
  107795. * @param impostor impostor to get friction from
  107796. * @returns friction value
  107797. */
  107798. getBodyFriction(impostor: PhysicsImpostor): number;
  107799. /**
  107800. * Sets friction of the impostor
  107801. * @param impostor impostor to set friction on
  107802. * @param friction friction value
  107803. */
  107804. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107805. /**
  107806. * Gets restitution of the impostor
  107807. * @param impostor impostor to get restitution from
  107808. * @returns restitution value
  107809. */
  107810. getBodyRestitution(impostor: PhysicsImpostor): number;
  107811. /**
  107812. * Sets resitution of the impostor
  107813. * @param impostor impostor to set resitution on
  107814. * @param restitution resitution value
  107815. */
  107816. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107817. /**
  107818. * Gets pressure inside the impostor
  107819. * @param impostor impostor to get pressure from
  107820. * @returns pressure value
  107821. */
  107822. getBodyPressure(impostor: PhysicsImpostor): number;
  107823. /**
  107824. * Sets pressure inside a soft body impostor
  107825. * Cloth and rope must remain 0 pressure
  107826. * @param impostor impostor to set pressure on
  107827. * @param pressure pressure value
  107828. */
  107829. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  107830. /**
  107831. * Gets stiffness of the impostor
  107832. * @param impostor impostor to get stiffness from
  107833. * @returns pressure value
  107834. */
  107835. getBodyStiffness(impostor: PhysicsImpostor): number;
  107836. /**
  107837. * Sets stiffness of the impostor
  107838. * @param impostor impostor to set stiffness on
  107839. * @param stiffness stiffness value from 0 to 1
  107840. */
  107841. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  107842. /**
  107843. * Gets velocityIterations of the impostor
  107844. * @param impostor impostor to get velocity iterations from
  107845. * @returns velocityIterations value
  107846. */
  107847. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  107848. /**
  107849. * Sets velocityIterations of the impostor
  107850. * @param impostor impostor to set velocity iterations on
  107851. * @param velocityIterations velocityIterations value
  107852. */
  107853. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  107854. /**
  107855. * Gets positionIterations of the impostor
  107856. * @param impostor impostor to get position iterations from
  107857. * @returns positionIterations value
  107858. */
  107859. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  107860. /**
  107861. * Sets positionIterations of the impostor
  107862. * @param impostor impostor to set position on
  107863. * @param positionIterations positionIterations value
  107864. */
  107865. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  107866. /**
  107867. * Append an anchor to a cloth object
  107868. * @param impostor is the cloth impostor to add anchor to
  107869. * @param otherImpostor is the rigid impostor to anchor to
  107870. * @param width ratio across width from 0 to 1
  107871. * @param height ratio up height from 0 to 1
  107872. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  107873. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107874. */
  107875. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107876. /**
  107877. * Append an hook to a rope object
  107878. * @param impostor is the rope impostor to add hook to
  107879. * @param otherImpostor is the rigid impostor to hook to
  107880. * @param length ratio along the rope from 0 to 1
  107881. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  107882. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  107883. */
  107884. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  107885. /**
  107886. * Sleeps the physics body and stops it from being active
  107887. * @param impostor impostor to sleep
  107888. */
  107889. sleepBody(impostor: PhysicsImpostor): void;
  107890. /**
  107891. * Activates the physics body
  107892. * @param impostor impostor to activate
  107893. */
  107894. wakeUpBody(impostor: PhysicsImpostor): void;
  107895. /**
  107896. * Updates the distance parameters of the joint
  107897. * @param joint joint to update
  107898. * @param maxDistance maximum distance of the joint
  107899. * @param minDistance minimum distance of the joint
  107900. */
  107901. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107902. /**
  107903. * Sets a motor on the joint
  107904. * @param joint joint to set motor on
  107905. * @param speed speed of the motor
  107906. * @param maxForce maximum force of the motor
  107907. * @param motorIndex index of the motor
  107908. */
  107909. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107910. /**
  107911. * Sets the motors limit
  107912. * @param joint joint to set limit on
  107913. * @param upperLimit upper limit
  107914. * @param lowerLimit lower limit
  107915. */
  107916. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107917. /**
  107918. * Syncs the position and rotation of a mesh with the impostor
  107919. * @param mesh mesh to sync
  107920. * @param impostor impostor to update the mesh with
  107921. */
  107922. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107923. /**
  107924. * Gets the radius of the impostor
  107925. * @param impostor impostor to get radius from
  107926. * @returns the radius
  107927. */
  107928. getRadius(impostor: PhysicsImpostor): number;
  107929. /**
  107930. * Gets the box size of the impostor
  107931. * @param impostor impostor to get box size from
  107932. * @param result the resulting box size
  107933. */
  107934. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107935. /**
  107936. * Disposes of the impostor
  107937. */
  107938. dispose(): void;
  107939. /**
  107940. * Does a raycast in the physics world
  107941. * @param from when should the ray start?
  107942. * @param to when should the ray end?
  107943. * @returns PhysicsRaycastResult
  107944. */
  107945. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107946. }
  107947. }
  107948. declare module BABYLON {
  107949. interface AbstractScene {
  107950. /**
  107951. * The list of reflection probes added to the scene
  107952. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107953. */
  107954. reflectionProbes: Array<ReflectionProbe>;
  107955. /**
  107956. * Removes the given reflection probe from this scene.
  107957. * @param toRemove The reflection probe to remove
  107958. * @returns The index of the removed reflection probe
  107959. */
  107960. removeReflectionProbe(toRemove: ReflectionProbe): number;
  107961. /**
  107962. * Adds the given reflection probe to this scene.
  107963. * @param newReflectionProbe The reflection probe to add
  107964. */
  107965. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  107966. }
  107967. /**
  107968. * Class used to generate realtime reflection / refraction cube textures
  107969. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  107970. */
  107971. export class ReflectionProbe {
  107972. /** defines the name of the probe */
  107973. name: string;
  107974. private _scene;
  107975. private _renderTargetTexture;
  107976. private _projectionMatrix;
  107977. private _viewMatrix;
  107978. private _target;
  107979. private _add;
  107980. private _attachedMesh;
  107981. private _invertYAxis;
  107982. /** Gets or sets probe position (center of the cube map) */
  107983. position: Vector3;
  107984. /**
  107985. * Creates a new reflection probe
  107986. * @param name defines the name of the probe
  107987. * @param size defines the texture resolution (for each face)
  107988. * @param scene defines the hosting scene
  107989. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  107990. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  107991. */
  107992. constructor(
  107993. /** defines the name of the probe */
  107994. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  107995. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  107996. samples: number;
  107997. /** Gets or sets the refresh rate to use (on every frame by default) */
  107998. refreshRate: number;
  107999. /**
  108000. * Gets the hosting scene
  108001. * @returns a Scene
  108002. */
  108003. getScene(): Scene;
  108004. /** Gets the internal CubeTexture used to render to */
  108005. readonly cubeTexture: RenderTargetTexture;
  108006. /** Gets the list of meshes to render */
  108007. readonly renderList: Nullable<AbstractMesh[]>;
  108008. /**
  108009. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108010. * @param mesh defines the mesh to attach to
  108011. */
  108012. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108013. /**
  108014. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108015. * @param renderingGroupId The rendering group id corresponding to its index
  108016. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108017. */
  108018. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108019. /**
  108020. * Clean all associated resources
  108021. */
  108022. dispose(): void;
  108023. /**
  108024. * Converts the reflection probe information to a readable string for debug purpose.
  108025. * @param fullDetails Supports for multiple levels of logging within scene loading
  108026. * @returns the human readable reflection probe info
  108027. */
  108028. toString(fullDetails?: boolean): string;
  108029. /**
  108030. * Get the class name of the relfection probe.
  108031. * @returns "ReflectionProbe"
  108032. */
  108033. getClassName(): string;
  108034. /**
  108035. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108036. * @returns The JSON representation of the texture
  108037. */
  108038. serialize(): any;
  108039. /**
  108040. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108041. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108042. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108043. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108044. * @returns The parsed reflection probe if successful
  108045. */
  108046. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108047. }
  108048. }
  108049. declare module BABYLON {
  108050. /** @hidden */
  108051. export var _BabylonLoaderRegistered: boolean;
  108052. }
  108053. declare module BABYLON {
  108054. /**
  108055. * The Physically based simple base material of BJS.
  108056. *
  108057. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108058. * It is used as the base class for both the specGloss and metalRough conventions.
  108059. */
  108060. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108061. /**
  108062. * Number of Simultaneous lights allowed on the material.
  108063. */
  108064. maxSimultaneousLights: number;
  108065. /**
  108066. * If sets to true, disables all the lights affecting the material.
  108067. */
  108068. disableLighting: boolean;
  108069. /**
  108070. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108071. */
  108072. environmentTexture: BaseTexture;
  108073. /**
  108074. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108075. */
  108076. invertNormalMapX: boolean;
  108077. /**
  108078. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108079. */
  108080. invertNormalMapY: boolean;
  108081. /**
  108082. * Normal map used in the model.
  108083. */
  108084. normalTexture: BaseTexture;
  108085. /**
  108086. * Emissivie color used to self-illuminate the model.
  108087. */
  108088. emissiveColor: Color3;
  108089. /**
  108090. * Emissivie texture used to self-illuminate the model.
  108091. */
  108092. emissiveTexture: BaseTexture;
  108093. /**
  108094. * Occlusion Channel Strenght.
  108095. */
  108096. occlusionStrength: number;
  108097. /**
  108098. * Occlusion Texture of the material (adding extra occlusion effects).
  108099. */
  108100. occlusionTexture: BaseTexture;
  108101. /**
  108102. * Defines the alpha limits in alpha test mode.
  108103. */
  108104. alphaCutOff: number;
  108105. /**
  108106. * Gets the current double sided mode.
  108107. */
  108108. /**
  108109. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108110. */
  108111. doubleSided: boolean;
  108112. /**
  108113. * Stores the pre-calculated light information of a mesh in a texture.
  108114. */
  108115. lightmapTexture: BaseTexture;
  108116. /**
  108117. * If true, the light map contains occlusion information instead of lighting info.
  108118. */
  108119. useLightmapAsShadowmap: boolean;
  108120. /**
  108121. * Instantiates a new PBRMaterial instance.
  108122. *
  108123. * @param name The material name
  108124. * @param scene The scene the material will be use in.
  108125. */
  108126. constructor(name: string, scene: Scene);
  108127. getClassName(): string;
  108128. }
  108129. }
  108130. declare module BABYLON {
  108131. /**
  108132. * The PBR material of BJS following the metal roughness convention.
  108133. *
  108134. * This fits to the PBR convention in the GLTF definition:
  108135. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108136. */
  108137. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108138. /**
  108139. * The base color has two different interpretations depending on the value of metalness.
  108140. * When the material is a metal, the base color is the specific measured reflectance value
  108141. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108142. * of the material.
  108143. */
  108144. baseColor: Color3;
  108145. /**
  108146. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108147. * well as opacity information in the alpha channel.
  108148. */
  108149. baseTexture: BaseTexture;
  108150. /**
  108151. * Specifies the metallic scalar value of the material.
  108152. * Can also be used to scale the metalness values of the metallic texture.
  108153. */
  108154. metallic: number;
  108155. /**
  108156. * Specifies the roughness scalar value of the material.
  108157. * Can also be used to scale the roughness values of the metallic texture.
  108158. */
  108159. roughness: number;
  108160. /**
  108161. * Texture containing both the metallic value in the B channel and the
  108162. * roughness value in the G channel to keep better precision.
  108163. */
  108164. metallicRoughnessTexture: BaseTexture;
  108165. /**
  108166. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108167. *
  108168. * @param name The material name
  108169. * @param scene The scene the material will be use in.
  108170. */
  108171. constructor(name: string, scene: Scene);
  108172. /**
  108173. * Return the currrent class name of the material.
  108174. */
  108175. getClassName(): string;
  108176. /**
  108177. * Makes a duplicate of the current material.
  108178. * @param name - name to use for the new material.
  108179. */
  108180. clone(name: string): PBRMetallicRoughnessMaterial;
  108181. /**
  108182. * Serialize the material to a parsable JSON object.
  108183. */
  108184. serialize(): any;
  108185. /**
  108186. * Parses a JSON object correponding to the serialize function.
  108187. */
  108188. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108189. }
  108190. }
  108191. declare module BABYLON {
  108192. /**
  108193. * The PBR material of BJS following the specular glossiness convention.
  108194. *
  108195. * This fits to the PBR convention in the GLTF definition:
  108196. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108197. */
  108198. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108199. /**
  108200. * Specifies the diffuse color of the material.
  108201. */
  108202. diffuseColor: Color3;
  108203. /**
  108204. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108205. * channel.
  108206. */
  108207. diffuseTexture: BaseTexture;
  108208. /**
  108209. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108210. */
  108211. specularColor: Color3;
  108212. /**
  108213. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108214. */
  108215. glossiness: number;
  108216. /**
  108217. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108218. */
  108219. specularGlossinessTexture: BaseTexture;
  108220. /**
  108221. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108222. *
  108223. * @param name The material name
  108224. * @param scene The scene the material will be use in.
  108225. */
  108226. constructor(name: string, scene: Scene);
  108227. /**
  108228. * Return the currrent class name of the material.
  108229. */
  108230. getClassName(): string;
  108231. /**
  108232. * Makes a duplicate of the current material.
  108233. * @param name - name to use for the new material.
  108234. */
  108235. clone(name: string): PBRSpecularGlossinessMaterial;
  108236. /**
  108237. * Serialize the material to a parsable JSON object.
  108238. */
  108239. serialize(): any;
  108240. /**
  108241. * Parses a JSON object correponding to the serialize function.
  108242. */
  108243. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108244. }
  108245. }
  108246. declare module BABYLON {
  108247. /**
  108248. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108249. * It can help converting any input color in a desired output one. This can then be used to create effects
  108250. * from sepia, black and white to sixties or futuristic rendering...
  108251. *
  108252. * The only supported format is currently 3dl.
  108253. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108254. */
  108255. export class ColorGradingTexture extends BaseTexture {
  108256. /**
  108257. * The current texture matrix. (will always be identity in color grading texture)
  108258. */
  108259. private _textureMatrix;
  108260. /**
  108261. * The texture URL.
  108262. */
  108263. url: string;
  108264. /**
  108265. * Empty line regex stored for GC.
  108266. */
  108267. private static _noneEmptyLineRegex;
  108268. private _engine;
  108269. /**
  108270. * Instantiates a ColorGradingTexture from the following parameters.
  108271. *
  108272. * @param url The location of the color gradind data (currently only supporting 3dl)
  108273. * @param scene The scene the texture will be used in
  108274. */
  108275. constructor(url: string, scene: Scene);
  108276. /**
  108277. * Returns the texture matrix used in most of the material.
  108278. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108279. */
  108280. getTextureMatrix(): Matrix;
  108281. /**
  108282. * Occurs when the file being loaded is a .3dl LUT file.
  108283. */
  108284. private load3dlTexture;
  108285. /**
  108286. * Starts the loading process of the texture.
  108287. */
  108288. private loadTexture;
  108289. /**
  108290. * Clones the color gradind texture.
  108291. */
  108292. clone(): ColorGradingTexture;
  108293. /**
  108294. * Called during delayed load for textures.
  108295. */
  108296. delayLoad(): void;
  108297. /**
  108298. * Parses a color grading texture serialized by Babylon.
  108299. * @param parsedTexture The texture information being parsedTexture
  108300. * @param scene The scene to load the texture in
  108301. * @param rootUrl The root url of the data assets to load
  108302. * @return A color gradind texture
  108303. */
  108304. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108305. /**
  108306. * Serializes the LUT texture to json format.
  108307. */
  108308. serialize(): any;
  108309. }
  108310. }
  108311. declare module BABYLON {
  108312. /**
  108313. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108314. */
  108315. export class EquiRectangularCubeTexture extends BaseTexture {
  108316. /** The six faces of the cube. */
  108317. private static _FacesMapping;
  108318. private _noMipmap;
  108319. private _onLoad;
  108320. private _onError;
  108321. /** The size of the cubemap. */
  108322. private _size;
  108323. /** The buffer of the image. */
  108324. private _buffer;
  108325. /** The width of the input image. */
  108326. private _width;
  108327. /** The height of the input image. */
  108328. private _height;
  108329. /** The URL to the image. */
  108330. url: string;
  108331. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108332. coordinatesMode: number;
  108333. /**
  108334. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108335. * @param url The location of the image
  108336. * @param scene The scene the texture will be used in
  108337. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108338. * @param noMipmap Forces to not generate the mipmap if true
  108339. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108340. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108341. * @param onLoad — defines a callback called when texture is loaded
  108342. * @param onError — defines a callback called if there is an error
  108343. */
  108344. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108345. /**
  108346. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108347. */
  108348. private loadImage;
  108349. /**
  108350. * Convert the image buffer into a cubemap and create a CubeTexture.
  108351. */
  108352. private loadTexture;
  108353. /**
  108354. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108355. * @param buffer The ArrayBuffer that should be converted.
  108356. * @returns The buffer as Float32Array.
  108357. */
  108358. private getFloat32ArrayFromArrayBuffer;
  108359. /**
  108360. * Get the current class name of the texture useful for serialization or dynamic coding.
  108361. * @returns "EquiRectangularCubeTexture"
  108362. */
  108363. getClassName(): string;
  108364. /**
  108365. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108366. * @returns A clone of the current EquiRectangularCubeTexture.
  108367. */
  108368. clone(): EquiRectangularCubeTexture;
  108369. }
  108370. }
  108371. declare module BABYLON {
  108372. /**
  108373. * Based on jsTGALoader - Javascript loader for TGA file
  108374. * By Vincent Thibault
  108375. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108376. */
  108377. export class TGATools {
  108378. private static _TYPE_INDEXED;
  108379. private static _TYPE_RGB;
  108380. private static _TYPE_GREY;
  108381. private static _TYPE_RLE_INDEXED;
  108382. private static _TYPE_RLE_RGB;
  108383. private static _TYPE_RLE_GREY;
  108384. private static _ORIGIN_MASK;
  108385. private static _ORIGIN_SHIFT;
  108386. private static _ORIGIN_BL;
  108387. private static _ORIGIN_BR;
  108388. private static _ORIGIN_UL;
  108389. private static _ORIGIN_UR;
  108390. /**
  108391. * Gets the header of a TGA file
  108392. * @param data defines the TGA data
  108393. * @returns the header
  108394. */
  108395. static GetTGAHeader(data: Uint8Array): any;
  108396. /**
  108397. * Uploads TGA content to a Babylon Texture
  108398. * @hidden
  108399. */
  108400. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108401. /** @hidden */
  108402. 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;
  108403. /** @hidden */
  108404. 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;
  108405. /** @hidden */
  108406. 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;
  108407. /** @hidden */
  108408. 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;
  108409. /** @hidden */
  108410. 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;
  108411. /** @hidden */
  108412. 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;
  108413. }
  108414. }
  108415. declare module BABYLON {
  108416. /**
  108417. * Implementation of the TGA Texture Loader.
  108418. * @hidden
  108419. */
  108420. export class _TGATextureLoader implements IInternalTextureLoader {
  108421. /**
  108422. * Defines wether the loader supports cascade loading the different faces.
  108423. */
  108424. readonly supportCascades: boolean;
  108425. /**
  108426. * This returns if the loader support the current file information.
  108427. * @param extension defines the file extension of the file being loaded
  108428. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108429. * @param fallback defines the fallback internal texture if any
  108430. * @param isBase64 defines whether the texture is encoded as a base64
  108431. * @param isBuffer defines whether the texture data are stored as a buffer
  108432. * @returns true if the loader can load the specified file
  108433. */
  108434. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108435. /**
  108436. * Transform the url before loading if required.
  108437. * @param rootUrl the url of the texture
  108438. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108439. * @returns the transformed texture
  108440. */
  108441. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108442. /**
  108443. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108444. * @param rootUrl the url of the texture
  108445. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108446. * @returns the fallback texture
  108447. */
  108448. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108449. /**
  108450. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108451. * @param data contains the texture data
  108452. * @param texture defines the BabylonJS internal texture
  108453. * @param createPolynomials will be true if polynomials have been requested
  108454. * @param onLoad defines the callback to trigger once the texture is ready
  108455. * @param onError defines the callback to trigger in case of error
  108456. */
  108457. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108458. /**
  108459. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108460. * @param data contains the texture data
  108461. * @param texture defines the BabylonJS internal texture
  108462. * @param callback defines the method to call once ready to upload
  108463. */
  108464. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108465. }
  108466. }
  108467. declare module BABYLON {
  108468. /**
  108469. * 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.
  108470. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108471. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108472. */
  108473. export class CustomProceduralTexture extends ProceduralTexture {
  108474. private _animate;
  108475. private _time;
  108476. private _config;
  108477. private _texturePath;
  108478. /**
  108479. * Instantiates a new Custom Procedural Texture.
  108480. * 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.
  108481. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108482. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108483. * @param name Define the name of the texture
  108484. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108485. * @param size Define the size of the texture to create
  108486. * @param scene Define the scene the texture belongs to
  108487. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108488. * @param generateMipMaps Define if the texture should creates mip maps or not
  108489. */
  108490. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108491. private _loadJson;
  108492. /**
  108493. * Is the texture ready to be used ? (rendered at least once)
  108494. * @returns true if ready, otherwise, false.
  108495. */
  108496. isReady(): boolean;
  108497. /**
  108498. * Render the texture to its associated render target.
  108499. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108500. */
  108501. render(useCameraPostProcess?: boolean): void;
  108502. /**
  108503. * Update the list of dependant textures samplers in the shader.
  108504. */
  108505. updateTextures(): void;
  108506. /**
  108507. * Update the uniform values of the procedural texture in the shader.
  108508. */
  108509. updateShaderUniforms(): void;
  108510. /**
  108511. * Define if the texture animates or not.
  108512. */
  108513. animate: boolean;
  108514. }
  108515. }
  108516. declare module BABYLON {
  108517. /** @hidden */
  108518. export var noisePixelShader: {
  108519. name: string;
  108520. shader: string;
  108521. };
  108522. }
  108523. declare module BABYLON {
  108524. /**
  108525. * Class used to generate noise procedural textures
  108526. */
  108527. export class NoiseProceduralTexture extends ProceduralTexture {
  108528. private _time;
  108529. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108530. brightness: number;
  108531. /** Defines the number of octaves to process */
  108532. octaves: number;
  108533. /** Defines the level of persistence (0.8 by default) */
  108534. persistence: number;
  108535. /** Gets or sets animation speed factor (default is 1) */
  108536. animationSpeedFactor: number;
  108537. /**
  108538. * Creates a new NoiseProceduralTexture
  108539. * @param name defines the name fo the texture
  108540. * @param size defines the size of the texture (default is 256)
  108541. * @param scene defines the hosting scene
  108542. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108543. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108544. */
  108545. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108546. private _updateShaderUniforms;
  108547. protected _getDefines(): string;
  108548. /** Generate the current state of the procedural texture */
  108549. render(useCameraPostProcess?: boolean): void;
  108550. /**
  108551. * Serializes this noise procedural texture
  108552. * @returns a serialized noise procedural texture object
  108553. */
  108554. serialize(): any;
  108555. /**
  108556. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108557. * @param parsedTexture defines parsed texture data
  108558. * @param scene defines the current scene
  108559. * @param rootUrl defines the root URL containing noise procedural texture information
  108560. * @returns a parsed NoiseProceduralTexture
  108561. */
  108562. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108563. }
  108564. }
  108565. declare module BABYLON {
  108566. /**
  108567. * Raw cube texture where the raw buffers are passed in
  108568. */
  108569. export class RawCubeTexture extends CubeTexture {
  108570. /**
  108571. * Creates a cube texture where the raw buffers are passed in.
  108572. * @param scene defines the scene the texture is attached to
  108573. * @param data defines the array of data to use to create each face
  108574. * @param size defines the size of the textures
  108575. * @param format defines the format of the data
  108576. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108577. * @param generateMipMaps defines if the engine should generate the mip levels
  108578. * @param invertY defines if data must be stored with Y axis inverted
  108579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108580. * @param compression defines the compression used (null by default)
  108581. */
  108582. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108583. /**
  108584. * Updates the raw cube texture.
  108585. * @param data defines the data to store
  108586. * @param format defines the data format
  108587. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108588. * @param invertY defines if data must be stored with Y axis inverted
  108589. * @param compression defines the compression used (null by default)
  108590. * @param level defines which level of the texture to update
  108591. */
  108592. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108593. /**
  108594. * Updates a raw cube texture with RGBD encoded data.
  108595. * @param data defines the array of data [mipmap][face] to use to create each face
  108596. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108597. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108598. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108599. * @returns a promsie that resolves when the operation is complete
  108600. */
  108601. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108602. /**
  108603. * Clones the raw cube texture.
  108604. * @return a new cube texture
  108605. */
  108606. clone(): CubeTexture;
  108607. /** @hidden */
  108608. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108609. }
  108610. }
  108611. declare module BABYLON {
  108612. /**
  108613. * Class used to store 3D textures containing user data
  108614. */
  108615. export class RawTexture3D extends Texture {
  108616. /** Gets or sets the texture format to use */
  108617. format: number;
  108618. private _engine;
  108619. /**
  108620. * Create a new RawTexture3D
  108621. * @param data defines the data of the texture
  108622. * @param width defines the width of the texture
  108623. * @param height defines the height of the texture
  108624. * @param depth defines the depth of the texture
  108625. * @param format defines the texture format to use
  108626. * @param scene defines the hosting scene
  108627. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108628. * @param invertY defines if texture must be stored with Y axis inverted
  108629. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108630. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108631. */
  108632. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108633. /** Gets or sets the texture format to use */
  108634. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108635. /**
  108636. * Update the texture with new data
  108637. * @param data defines the data to store in the texture
  108638. */
  108639. update(data: ArrayBufferView): void;
  108640. }
  108641. }
  108642. declare module BABYLON {
  108643. /**
  108644. * Creates a refraction texture used by refraction channel of the standard material.
  108645. * It is like a mirror but to see through a material.
  108646. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108647. */
  108648. export class RefractionTexture extends RenderTargetTexture {
  108649. /**
  108650. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108651. * 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.
  108652. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108653. */
  108654. refractionPlane: Plane;
  108655. /**
  108656. * Define how deep under the surface we should see.
  108657. */
  108658. depth: number;
  108659. /**
  108660. * Creates a refraction texture used by refraction channel of the standard material.
  108661. * It is like a mirror but to see through a material.
  108662. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108663. * @param name Define the texture name
  108664. * @param size Define the size of the underlying texture
  108665. * @param scene Define the scene the refraction belongs to
  108666. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108667. */
  108668. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108669. /**
  108670. * Clone the refraction texture.
  108671. * @returns the cloned texture
  108672. */
  108673. clone(): RefractionTexture;
  108674. /**
  108675. * Serialize the texture to a JSON representation you could use in Parse later on
  108676. * @returns the serialized JSON representation
  108677. */
  108678. serialize(): any;
  108679. }
  108680. }
  108681. declare module BABYLON {
  108682. /**
  108683. * Helper class to push actions to a pool of workers.
  108684. */
  108685. export class WorkerPool implements IDisposable {
  108686. private _workerInfos;
  108687. private _pendingActions;
  108688. /**
  108689. * Constructor
  108690. * @param workers Array of workers to use for actions
  108691. */
  108692. constructor(workers: Array<Worker>);
  108693. /**
  108694. * Terminates all workers and clears any pending actions.
  108695. */
  108696. dispose(): void;
  108697. /**
  108698. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108699. * pended until a worker has completed its action.
  108700. * @param action The action to perform. Call onComplete when the action is complete.
  108701. */
  108702. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108703. private _execute;
  108704. }
  108705. }
  108706. declare module BABYLON {
  108707. /**
  108708. * Configuration for Draco compression
  108709. */
  108710. export interface IDracoCompressionConfiguration {
  108711. /**
  108712. * Configuration for the decoder.
  108713. */
  108714. decoder?: {
  108715. /**
  108716. * The url to the WebAssembly module.
  108717. */
  108718. wasmUrl?: string;
  108719. /**
  108720. * The url to the WebAssembly binary.
  108721. */
  108722. wasmBinaryUrl?: string;
  108723. /**
  108724. * The url to the fallback JavaScript module.
  108725. */
  108726. fallbackUrl?: string;
  108727. };
  108728. }
  108729. /**
  108730. * Draco compression (https://google.github.io/draco/)
  108731. *
  108732. * This class wraps the Draco module.
  108733. *
  108734. * **Encoder**
  108735. *
  108736. * The encoder is not currently implemented.
  108737. *
  108738. * **Decoder**
  108739. *
  108740. * 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.
  108741. *
  108742. * To update the configuration, use the following code:
  108743. * ```javascript
  108744. * DracoCompression.Configuration = {
  108745. * decoder: {
  108746. * wasmUrl: "<url to the WebAssembly library>",
  108747. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  108748. * fallbackUrl: "<url to the fallback JavaScript library>",
  108749. * }
  108750. * };
  108751. * ```
  108752. *
  108753. * 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.
  108754. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  108755. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  108756. *
  108757. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  108758. * ```javascript
  108759. * var dracoCompression = new DracoCompression();
  108760. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  108761. * [VertexBuffer.PositionKind]: 0
  108762. * });
  108763. * ```
  108764. *
  108765. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  108766. */
  108767. export class DracoCompression implements IDisposable {
  108768. private _workerPoolPromise;
  108769. /**
  108770. * The configuration. Defaults to the following urls:
  108771. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  108772. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  108773. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  108774. */
  108775. static Configuration: IDracoCompressionConfiguration;
  108776. /**
  108777. * Returns true if the decoder is available.
  108778. */
  108779. static readonly DecoderAvailable: boolean;
  108780. /**
  108781. * Default number of workers to create when creating the draco compression object.
  108782. */
  108783. static DefaultNumWorkers: number;
  108784. private static GetDefaultNumWorkers;
  108785. /**
  108786. * Constructor
  108787. * @param numWorkers The number of workers for async operations
  108788. */
  108789. constructor(numWorkers?: number);
  108790. /**
  108791. * Stop all async operations and release resources.
  108792. */
  108793. dispose(): void;
  108794. /**
  108795. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  108796. * @returns a promise that resolves when ready
  108797. */
  108798. whenReadyAsync(): Promise<void>;
  108799. /**
  108800. * Decode Draco compressed mesh data to vertex data.
  108801. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  108802. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  108803. * @returns A promise that resolves with the decoded vertex data
  108804. */
  108805. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  108806. [kind: string]: number;
  108807. }): Promise<VertexData>;
  108808. /**
  108809. * The worker function that gets converted to a blob url to pass into a worker.
  108810. */
  108811. private static _Worker;
  108812. private _loadDecoderWasmBinaryAsync;
  108813. }
  108814. }
  108815. declare module BABYLON {
  108816. /**
  108817. * Class for building Constructive Solid Geometry
  108818. */
  108819. export class CSG {
  108820. private polygons;
  108821. /**
  108822. * The world matrix
  108823. */
  108824. matrix: Matrix;
  108825. /**
  108826. * Stores the position
  108827. */
  108828. position: Vector3;
  108829. /**
  108830. * Stores the rotation
  108831. */
  108832. rotation: Vector3;
  108833. /**
  108834. * Stores the rotation quaternion
  108835. */
  108836. rotationQuaternion: Nullable<Quaternion>;
  108837. /**
  108838. * Stores the scaling vector
  108839. */
  108840. scaling: Vector3;
  108841. /**
  108842. * Convert the Mesh to CSG
  108843. * @param mesh The Mesh to convert to CSG
  108844. * @returns A new CSG from the Mesh
  108845. */
  108846. static FromMesh(mesh: Mesh): CSG;
  108847. /**
  108848. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  108849. * @param polygons Polygons used to construct a CSG solid
  108850. */
  108851. private static FromPolygons;
  108852. /**
  108853. * Clones, or makes a deep copy, of the CSG
  108854. * @returns A new CSG
  108855. */
  108856. clone(): CSG;
  108857. /**
  108858. * Unions this CSG with another CSG
  108859. * @param csg The CSG to union against this CSG
  108860. * @returns The unioned CSG
  108861. */
  108862. union(csg: CSG): CSG;
  108863. /**
  108864. * Unions this CSG with another CSG in place
  108865. * @param csg The CSG to union against this CSG
  108866. */
  108867. unionInPlace(csg: CSG): void;
  108868. /**
  108869. * Subtracts this CSG with another CSG
  108870. * @param csg The CSG to subtract against this CSG
  108871. * @returns A new CSG
  108872. */
  108873. subtract(csg: CSG): CSG;
  108874. /**
  108875. * Subtracts this CSG with another CSG in place
  108876. * @param csg The CSG to subtact against this CSG
  108877. */
  108878. subtractInPlace(csg: CSG): void;
  108879. /**
  108880. * Intersect this CSG with another CSG
  108881. * @param csg The CSG to intersect against this CSG
  108882. * @returns A new CSG
  108883. */
  108884. intersect(csg: CSG): CSG;
  108885. /**
  108886. * Intersects this CSG with another CSG in place
  108887. * @param csg The CSG to intersect against this CSG
  108888. */
  108889. intersectInPlace(csg: CSG): void;
  108890. /**
  108891. * Return a new CSG solid with solid and empty space switched. This solid is
  108892. * not modified.
  108893. * @returns A new CSG solid with solid and empty space switched
  108894. */
  108895. inverse(): CSG;
  108896. /**
  108897. * Inverses the CSG in place
  108898. */
  108899. inverseInPlace(): void;
  108900. /**
  108901. * This is used to keep meshes transformations so they can be restored
  108902. * when we build back a Babylon Mesh
  108903. * NB : All CSG operations are performed in world coordinates
  108904. * @param csg The CSG to copy the transform attributes from
  108905. * @returns This CSG
  108906. */
  108907. copyTransformAttributes(csg: CSG): CSG;
  108908. /**
  108909. * Build Raw mesh from CSG
  108910. * Coordinates here are in world space
  108911. * @param name The name of the mesh geometry
  108912. * @param scene The Scene
  108913. * @param keepSubMeshes Specifies if the submeshes should be kept
  108914. * @returns A new Mesh
  108915. */
  108916. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  108917. /**
  108918. * Build Mesh from CSG taking material and transforms into account
  108919. * @param name The name of the Mesh
  108920. * @param material The material of the Mesh
  108921. * @param scene The Scene
  108922. * @param keepSubMeshes Specifies if submeshes should be kept
  108923. * @returns The new Mesh
  108924. */
  108925. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  108926. }
  108927. }
  108928. declare module BABYLON {
  108929. /**
  108930. * Class used to create a trail following a mesh
  108931. */
  108932. export class TrailMesh extends Mesh {
  108933. private _generator;
  108934. private _autoStart;
  108935. private _running;
  108936. private _diameter;
  108937. private _length;
  108938. private _sectionPolygonPointsCount;
  108939. private _sectionVectors;
  108940. private _sectionNormalVectors;
  108941. private _beforeRenderObserver;
  108942. /**
  108943. * @constructor
  108944. * @param name The value used by scene.getMeshByName() to do a lookup.
  108945. * @param generator The mesh to generate a trail.
  108946. * @param scene The scene to add this mesh to.
  108947. * @param diameter Diameter of trailing mesh. Default is 1.
  108948. * @param length Length of trailing mesh. Default is 60.
  108949. * @param autoStart Automatically start trailing mesh. Default true.
  108950. */
  108951. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  108952. /**
  108953. * "TrailMesh"
  108954. * @returns "TrailMesh"
  108955. */
  108956. getClassName(): string;
  108957. private _createMesh;
  108958. /**
  108959. * Start trailing mesh.
  108960. */
  108961. start(): void;
  108962. /**
  108963. * Stop trailing mesh.
  108964. */
  108965. stop(): void;
  108966. /**
  108967. * Update trailing mesh geometry.
  108968. */
  108969. update(): void;
  108970. /**
  108971. * Returns a new TrailMesh object.
  108972. * @param name is a string, the name given to the new mesh
  108973. * @param newGenerator use new generator object for cloned trail mesh
  108974. * @returns a new mesh
  108975. */
  108976. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  108977. /**
  108978. * Serializes this trail mesh
  108979. * @param serializationObject object to write serialization to
  108980. */
  108981. serialize(serializationObject: any): void;
  108982. /**
  108983. * Parses a serialized trail mesh
  108984. * @param parsedMesh the serialized mesh
  108985. * @param scene the scene to create the trail mesh in
  108986. * @returns the created trail mesh
  108987. */
  108988. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  108989. }
  108990. }
  108991. declare module BABYLON {
  108992. /**
  108993. * Class containing static functions to help procedurally build meshes
  108994. */
  108995. export class TorusKnotBuilder {
  108996. /**
  108997. * Creates a torus knot mesh
  108998. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  108999. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109000. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109001. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109002. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109003. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109004. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109005. * @param name defines the name of the mesh
  109006. * @param options defines the options used to create the mesh
  109007. * @param scene defines the hosting scene
  109008. * @returns the torus knot mesh
  109009. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109010. */
  109011. static CreateTorusKnot(name: string, options: {
  109012. radius?: number;
  109013. tube?: number;
  109014. radialSegments?: number;
  109015. tubularSegments?: number;
  109016. p?: number;
  109017. q?: number;
  109018. updatable?: boolean;
  109019. sideOrientation?: number;
  109020. frontUVs?: Vector4;
  109021. backUVs?: Vector4;
  109022. }, scene: any): Mesh;
  109023. }
  109024. }
  109025. declare module BABYLON {
  109026. /**
  109027. * Polygon
  109028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109029. */
  109030. export class Polygon {
  109031. /**
  109032. * Creates a rectangle
  109033. * @param xmin bottom X coord
  109034. * @param ymin bottom Y coord
  109035. * @param xmax top X coord
  109036. * @param ymax top Y coord
  109037. * @returns points that make the resulting rectation
  109038. */
  109039. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109040. /**
  109041. * Creates a circle
  109042. * @param radius radius of circle
  109043. * @param cx scale in x
  109044. * @param cy scale in y
  109045. * @param numberOfSides number of sides that make up the circle
  109046. * @returns points that make the resulting circle
  109047. */
  109048. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109049. /**
  109050. * Creates a polygon from input string
  109051. * @param input Input polygon data
  109052. * @returns the parsed points
  109053. */
  109054. static Parse(input: string): Vector2[];
  109055. /**
  109056. * Starts building a polygon from x and y coordinates
  109057. * @param x x coordinate
  109058. * @param y y coordinate
  109059. * @returns the started path2
  109060. */
  109061. static StartingAt(x: number, y: number): Path2;
  109062. }
  109063. /**
  109064. * Builds a polygon
  109065. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109066. */
  109067. export class PolygonMeshBuilder {
  109068. private _points;
  109069. private _outlinepoints;
  109070. private _holes;
  109071. private _name;
  109072. private _scene;
  109073. private _epoints;
  109074. private _eholes;
  109075. private _addToepoint;
  109076. /**
  109077. * Babylon reference to the earcut plugin.
  109078. */
  109079. bjsEarcut: any;
  109080. /**
  109081. * Creates a PolygonMeshBuilder
  109082. * @param name name of the builder
  109083. * @param contours Path of the polygon
  109084. * @param scene scene to add to when creating the mesh
  109085. * @param earcutInjection can be used to inject your own earcut reference
  109086. */
  109087. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109088. /**
  109089. * Adds a whole within the polygon
  109090. * @param hole Array of points defining the hole
  109091. * @returns this
  109092. */
  109093. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109094. /**
  109095. * Creates the polygon
  109096. * @param updatable If the mesh should be updatable
  109097. * @param depth The depth of the mesh created
  109098. * @returns the created mesh
  109099. */
  109100. build(updatable?: boolean, depth?: number): Mesh;
  109101. /**
  109102. * Creates the polygon
  109103. * @param depth The depth of the mesh created
  109104. * @returns the created VertexData
  109105. */
  109106. buildVertexData(depth?: number): VertexData;
  109107. /**
  109108. * Adds a side to the polygon
  109109. * @param positions points that make the polygon
  109110. * @param normals normals of the polygon
  109111. * @param uvs uvs of the polygon
  109112. * @param indices indices of the polygon
  109113. * @param bounds bounds of the polygon
  109114. * @param points points of the polygon
  109115. * @param depth depth of the polygon
  109116. * @param flip flip of the polygon
  109117. */
  109118. private addSide;
  109119. }
  109120. }
  109121. declare module BABYLON {
  109122. /**
  109123. * Class containing static functions to help procedurally build meshes
  109124. */
  109125. export class PolygonBuilder {
  109126. /**
  109127. * Creates a polygon mesh
  109128. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109129. * * 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
  109130. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109131. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109133. * * Remember you can only change the shape positions, not their number when updating a polygon
  109134. * @param name defines the name of the mesh
  109135. * @param options defines the options used to create the mesh
  109136. * @param scene defines the hosting scene
  109137. * @param earcutInjection can be used to inject your own earcut reference
  109138. * @returns the polygon mesh
  109139. */
  109140. static CreatePolygon(name: string, options: {
  109141. shape: Vector3[];
  109142. holes?: Vector3[][];
  109143. depth?: number;
  109144. faceUV?: Vector4[];
  109145. faceColors?: Color4[];
  109146. updatable?: boolean;
  109147. sideOrientation?: number;
  109148. frontUVs?: Vector4;
  109149. backUVs?: Vector4;
  109150. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109151. /**
  109152. * Creates an extruded polygon mesh, with depth in the Y direction.
  109153. * * 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)
  109154. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109155. * @param name defines the name of the mesh
  109156. * @param options defines the options used to create the mesh
  109157. * @param scene defines the hosting scene
  109158. * @param earcutInjection can be used to inject your own earcut reference
  109159. * @returns the polygon mesh
  109160. */
  109161. static ExtrudePolygon(name: string, options: {
  109162. shape: Vector3[];
  109163. holes?: Vector3[][];
  109164. depth?: number;
  109165. faceUV?: Vector4[];
  109166. faceColors?: Color4[];
  109167. updatable?: boolean;
  109168. sideOrientation?: number;
  109169. frontUVs?: Vector4;
  109170. backUVs?: Vector4;
  109171. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109172. }
  109173. }
  109174. declare module BABYLON {
  109175. /**
  109176. * Class containing static functions to help procedurally build meshes
  109177. */
  109178. export class LatheBuilder {
  109179. /**
  109180. * Creates lathe mesh.
  109181. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109182. * * 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
  109183. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109184. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109185. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109186. * * 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
  109187. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109188. * * 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
  109189. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109190. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109191. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109192. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109193. * @param name defines the name of the mesh
  109194. * @param options defines the options used to create the mesh
  109195. * @param scene defines the hosting scene
  109196. * @returns the lathe mesh
  109197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109198. */
  109199. static CreateLathe(name: string, options: {
  109200. shape: Vector3[];
  109201. radius?: number;
  109202. tessellation?: number;
  109203. clip?: number;
  109204. arc?: number;
  109205. closed?: boolean;
  109206. updatable?: boolean;
  109207. sideOrientation?: number;
  109208. frontUVs?: Vector4;
  109209. backUVs?: Vector4;
  109210. cap?: number;
  109211. invertUV?: boolean;
  109212. }, scene?: Nullable<Scene>): Mesh;
  109213. }
  109214. }
  109215. declare module BABYLON {
  109216. /**
  109217. * Class containing static functions to help procedurally build meshes
  109218. */
  109219. export class TubeBuilder {
  109220. /**
  109221. * Creates a tube mesh.
  109222. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109223. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109224. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109225. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109226. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109227. * * 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)
  109228. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109229. * * 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
  109230. * * 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
  109231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109232. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109233. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109235. * @param name defines the name of the mesh
  109236. * @param options defines the options used to create the mesh
  109237. * @param scene defines the hosting scene
  109238. * @returns the tube mesh
  109239. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109240. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109241. */
  109242. static CreateTube(name: string, options: {
  109243. path: Vector3[];
  109244. radius?: number;
  109245. tessellation?: number;
  109246. radiusFunction?: {
  109247. (i: number, distance: number): number;
  109248. };
  109249. cap?: number;
  109250. arc?: number;
  109251. updatable?: boolean;
  109252. sideOrientation?: number;
  109253. frontUVs?: Vector4;
  109254. backUVs?: Vector4;
  109255. instance?: Mesh;
  109256. invertUV?: boolean;
  109257. }, scene?: Nullable<Scene>): Mesh;
  109258. }
  109259. }
  109260. declare module BABYLON {
  109261. /**
  109262. * Class containing static functions to help procedurally build meshes
  109263. */
  109264. export class IcoSphereBuilder {
  109265. /**
  109266. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109267. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109268. * * 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`)
  109269. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109270. * * 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
  109271. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109272. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109274. * @param name defines the name of the mesh
  109275. * @param options defines the options used to create the mesh
  109276. * @param scene defines the hosting scene
  109277. * @returns the icosahedron mesh
  109278. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109279. */
  109280. static CreateIcoSphere(name: string, options: {
  109281. radius?: number;
  109282. radiusX?: number;
  109283. radiusY?: number;
  109284. radiusZ?: number;
  109285. flat?: boolean;
  109286. subdivisions?: number;
  109287. sideOrientation?: number;
  109288. frontUVs?: Vector4;
  109289. backUVs?: Vector4;
  109290. updatable?: boolean;
  109291. }, scene?: Nullable<Scene>): Mesh;
  109292. }
  109293. }
  109294. declare module BABYLON {
  109295. /**
  109296. * Class containing static functions to help procedurally build meshes
  109297. */
  109298. export class DecalBuilder {
  109299. /**
  109300. * Creates a decal mesh.
  109301. * 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
  109302. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109303. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109304. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109305. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109306. * @param name defines the name of the mesh
  109307. * @param sourceMesh defines the mesh where the decal must be applied
  109308. * @param options defines the options used to create the mesh
  109309. * @param scene defines the hosting scene
  109310. * @returns the decal mesh
  109311. * @see https://doc.babylonjs.com/how_to/decals
  109312. */
  109313. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109314. position?: Vector3;
  109315. normal?: Vector3;
  109316. size?: Vector3;
  109317. angle?: number;
  109318. }): Mesh;
  109319. }
  109320. }
  109321. declare module BABYLON {
  109322. /**
  109323. * Class containing static functions to help procedurally build meshes
  109324. */
  109325. export class MeshBuilder {
  109326. /**
  109327. * Creates a box mesh
  109328. * * The parameter `size` sets the size (float) of each box side (default 1)
  109329. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109330. * * 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)
  109331. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109332. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109333. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109334. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109335. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109336. * @param name defines the name of the mesh
  109337. * @param options defines the options used to create the mesh
  109338. * @param scene defines the hosting scene
  109339. * @returns the box mesh
  109340. */
  109341. static CreateBox(name: string, options: {
  109342. size?: number;
  109343. width?: number;
  109344. height?: number;
  109345. depth?: number;
  109346. faceUV?: Vector4[];
  109347. faceColors?: Color4[];
  109348. sideOrientation?: number;
  109349. frontUVs?: Vector4;
  109350. backUVs?: Vector4;
  109351. updatable?: boolean;
  109352. }, scene?: Nullable<Scene>): Mesh;
  109353. /**
  109354. * Creates a sphere mesh
  109355. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109356. * * 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`)
  109357. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109358. * * 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
  109359. * * 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)
  109360. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109361. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109363. * @param name defines the name of the mesh
  109364. * @param options defines the options used to create the mesh
  109365. * @param scene defines the hosting scene
  109366. * @returns the sphere mesh
  109367. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109368. */
  109369. static CreateSphere(name: string, options: {
  109370. segments?: number;
  109371. diameter?: number;
  109372. diameterX?: number;
  109373. diameterY?: number;
  109374. diameterZ?: number;
  109375. arc?: number;
  109376. slice?: number;
  109377. sideOrientation?: number;
  109378. frontUVs?: Vector4;
  109379. backUVs?: Vector4;
  109380. updatable?: boolean;
  109381. }, scene?: Nullable<Scene>): Mesh;
  109382. /**
  109383. * Creates a plane polygonal mesh. By default, this is a disc
  109384. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109385. * * 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
  109386. * * 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
  109387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109390. * @param name defines the name of the mesh
  109391. * @param options defines the options used to create the mesh
  109392. * @param scene defines the hosting scene
  109393. * @returns the plane polygonal mesh
  109394. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109395. */
  109396. static CreateDisc(name: string, options: {
  109397. radius?: number;
  109398. tessellation?: number;
  109399. arc?: number;
  109400. updatable?: boolean;
  109401. sideOrientation?: number;
  109402. frontUVs?: Vector4;
  109403. backUVs?: Vector4;
  109404. }, scene?: Nullable<Scene>): Mesh;
  109405. /**
  109406. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109407. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109408. * * 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`)
  109409. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109410. * * 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
  109411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109414. * @param name defines the name of the mesh
  109415. * @param options defines the options used to create the mesh
  109416. * @param scene defines the hosting scene
  109417. * @returns the icosahedron mesh
  109418. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109419. */
  109420. static CreateIcoSphere(name: string, options: {
  109421. radius?: number;
  109422. radiusX?: number;
  109423. radiusY?: number;
  109424. radiusZ?: number;
  109425. flat?: boolean;
  109426. subdivisions?: number;
  109427. sideOrientation?: number;
  109428. frontUVs?: Vector4;
  109429. backUVs?: Vector4;
  109430. updatable?: boolean;
  109431. }, scene?: Nullable<Scene>): Mesh;
  109432. /**
  109433. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109434. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109435. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109436. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109437. * * 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
  109438. * * 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
  109439. * * 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
  109440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109443. * * 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
  109444. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109445. * * 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
  109446. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109447. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109448. * @param name defines the name of the mesh
  109449. * @param options defines the options used to create the mesh
  109450. * @param scene defines the hosting scene
  109451. * @returns the ribbon mesh
  109452. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109453. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109454. */
  109455. static CreateRibbon(name: string, options: {
  109456. pathArray: Vector3[][];
  109457. closeArray?: boolean;
  109458. closePath?: boolean;
  109459. offset?: number;
  109460. updatable?: boolean;
  109461. sideOrientation?: number;
  109462. frontUVs?: Vector4;
  109463. backUVs?: Vector4;
  109464. instance?: Mesh;
  109465. invertUV?: boolean;
  109466. uvs?: Vector2[];
  109467. colors?: Color4[];
  109468. }, scene?: Nullable<Scene>): Mesh;
  109469. /**
  109470. * Creates a cylinder or a cone mesh
  109471. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109472. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109473. * * 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.
  109474. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109475. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109476. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109477. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109478. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109479. * * 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).
  109480. * * 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
  109481. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109482. * * 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
  109483. * * 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.
  109484. * * If `enclose` is false, a ring surface is one element.
  109485. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109486. * * 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
  109487. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109488. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109490. * @param name defines the name of the mesh
  109491. * @param options defines the options used to create the mesh
  109492. * @param scene defines the hosting scene
  109493. * @returns the cylinder mesh
  109494. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109495. */
  109496. static CreateCylinder(name: string, options: {
  109497. height?: number;
  109498. diameterTop?: number;
  109499. diameterBottom?: number;
  109500. diameter?: number;
  109501. tessellation?: number;
  109502. subdivisions?: number;
  109503. arc?: number;
  109504. faceColors?: Color4[];
  109505. faceUV?: Vector4[];
  109506. updatable?: boolean;
  109507. hasRings?: boolean;
  109508. enclose?: boolean;
  109509. sideOrientation?: number;
  109510. frontUVs?: Vector4;
  109511. backUVs?: Vector4;
  109512. }, scene?: Nullable<Scene>): Mesh;
  109513. /**
  109514. * Creates a torus mesh
  109515. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109516. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109517. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109518. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109519. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109520. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109521. * @param name defines the name of the mesh
  109522. * @param options defines the options used to create the mesh
  109523. * @param scene defines the hosting scene
  109524. * @returns the torus mesh
  109525. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109526. */
  109527. static CreateTorus(name: string, options: {
  109528. diameter?: number;
  109529. thickness?: number;
  109530. tessellation?: number;
  109531. updatable?: boolean;
  109532. sideOrientation?: number;
  109533. frontUVs?: Vector4;
  109534. backUVs?: Vector4;
  109535. }, scene?: Nullable<Scene>): Mesh;
  109536. /**
  109537. * Creates a torus knot mesh
  109538. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109539. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109540. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109541. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109542. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109543. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109545. * @param name defines the name of the mesh
  109546. * @param options defines the options used to create the mesh
  109547. * @param scene defines the hosting scene
  109548. * @returns the torus knot mesh
  109549. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109550. */
  109551. static CreateTorusKnot(name: string, options: {
  109552. radius?: number;
  109553. tube?: number;
  109554. radialSegments?: number;
  109555. tubularSegments?: number;
  109556. p?: number;
  109557. q?: number;
  109558. updatable?: boolean;
  109559. sideOrientation?: number;
  109560. frontUVs?: Vector4;
  109561. backUVs?: Vector4;
  109562. }, scene?: Nullable<Scene>): Mesh;
  109563. /**
  109564. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109565. * * 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
  109566. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109567. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109568. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109569. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109570. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109571. * * 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
  109572. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109574. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109575. * @param name defines the name of the new line system
  109576. * @param options defines the options used to create the line system
  109577. * @param scene defines the hosting scene
  109578. * @returns a new line system mesh
  109579. */
  109580. static CreateLineSystem(name: string, options: {
  109581. lines: Vector3[][];
  109582. updatable?: boolean;
  109583. instance?: Nullable<LinesMesh>;
  109584. colors?: Nullable<Color4[][]>;
  109585. useVertexAlpha?: boolean;
  109586. }, scene: Nullable<Scene>): LinesMesh;
  109587. /**
  109588. * Creates a line mesh
  109589. * 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
  109590. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109591. * * The parameter `points` is an array successive Vector3
  109592. * * 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
  109593. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109594. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109595. * * When updating an instance, remember that only point positions can change, not the number of points
  109596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109598. * @param name defines the name of the new line system
  109599. * @param options defines the options used to create the line system
  109600. * @param scene defines the hosting scene
  109601. * @returns a new line mesh
  109602. */
  109603. static CreateLines(name: string, options: {
  109604. points: Vector3[];
  109605. updatable?: boolean;
  109606. instance?: Nullable<LinesMesh>;
  109607. colors?: Color4[];
  109608. useVertexAlpha?: boolean;
  109609. }, scene?: Nullable<Scene>): LinesMesh;
  109610. /**
  109611. * Creates a dashed line mesh
  109612. * * 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
  109613. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109614. * * The parameter `points` is an array successive Vector3
  109615. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109616. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109617. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109618. * * 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
  109619. * * When updating an instance, remember that only point positions can change, not the number of points
  109620. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109621. * @param name defines the name of the mesh
  109622. * @param options defines the options used to create the mesh
  109623. * @param scene defines the hosting scene
  109624. * @returns the dashed line mesh
  109625. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109626. */
  109627. static CreateDashedLines(name: string, options: {
  109628. points: Vector3[];
  109629. dashSize?: number;
  109630. gapSize?: number;
  109631. dashNb?: number;
  109632. updatable?: boolean;
  109633. instance?: LinesMesh;
  109634. }, scene?: Nullable<Scene>): LinesMesh;
  109635. /**
  109636. * 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.
  109637. * * 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.
  109638. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109639. * * 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.
  109640. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109641. * * 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
  109642. * * 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
  109643. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109644. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109645. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109646. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109648. * @param name defines the name of the mesh
  109649. * @param options defines the options used to create the mesh
  109650. * @param scene defines the hosting scene
  109651. * @returns the extruded shape mesh
  109652. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109653. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109654. */
  109655. static ExtrudeShape(name: string, options: {
  109656. shape: Vector3[];
  109657. path: Vector3[];
  109658. scale?: number;
  109659. rotation?: number;
  109660. cap?: number;
  109661. updatable?: boolean;
  109662. sideOrientation?: number;
  109663. frontUVs?: Vector4;
  109664. backUVs?: Vector4;
  109665. instance?: Mesh;
  109666. invertUV?: boolean;
  109667. }, scene?: Nullable<Scene>): Mesh;
  109668. /**
  109669. * Creates an custom extruded shape mesh.
  109670. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109671. * * 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.
  109672. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109673. * * 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
  109674. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109675. * * 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
  109676. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109677. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109678. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109679. * * 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
  109680. * * 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
  109681. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109683. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109684. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109686. * @param name defines the name of the mesh
  109687. * @param options defines the options used to create the mesh
  109688. * @param scene defines the hosting scene
  109689. * @returns the custom extruded shape mesh
  109690. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109691. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109692. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109693. */
  109694. static ExtrudeShapeCustom(name: string, options: {
  109695. shape: Vector3[];
  109696. path: Vector3[];
  109697. scaleFunction?: any;
  109698. rotationFunction?: any;
  109699. ribbonCloseArray?: boolean;
  109700. ribbonClosePath?: boolean;
  109701. cap?: number;
  109702. updatable?: boolean;
  109703. sideOrientation?: number;
  109704. frontUVs?: Vector4;
  109705. backUVs?: Vector4;
  109706. instance?: Mesh;
  109707. invertUV?: boolean;
  109708. }, scene?: Nullable<Scene>): Mesh;
  109709. /**
  109710. * Creates lathe mesh.
  109711. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109712. * * 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
  109713. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109714. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109715. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109716. * * 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
  109717. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109718. * * 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
  109719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109720. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109723. * @param name defines the name of the mesh
  109724. * @param options defines the options used to create the mesh
  109725. * @param scene defines the hosting scene
  109726. * @returns the lathe mesh
  109727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109728. */
  109729. static CreateLathe(name: string, options: {
  109730. shape: Vector3[];
  109731. radius?: number;
  109732. tessellation?: number;
  109733. clip?: number;
  109734. arc?: number;
  109735. closed?: boolean;
  109736. updatable?: boolean;
  109737. sideOrientation?: number;
  109738. frontUVs?: Vector4;
  109739. backUVs?: Vector4;
  109740. cap?: number;
  109741. invertUV?: boolean;
  109742. }, scene?: Nullable<Scene>): Mesh;
  109743. /**
  109744. * Creates a plane mesh
  109745. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  109746. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  109747. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  109748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109749. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109750. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109751. * @param name defines the name of the mesh
  109752. * @param options defines the options used to create the mesh
  109753. * @param scene defines the hosting scene
  109754. * @returns the plane mesh
  109755. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  109756. */
  109757. static CreatePlane(name: string, options: {
  109758. size?: number;
  109759. width?: number;
  109760. height?: number;
  109761. sideOrientation?: number;
  109762. frontUVs?: Vector4;
  109763. backUVs?: Vector4;
  109764. updatable?: boolean;
  109765. sourcePlane?: Plane;
  109766. }, scene?: Nullable<Scene>): Mesh;
  109767. /**
  109768. * Creates a ground mesh
  109769. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  109770. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  109771. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109772. * @param name defines the name of the mesh
  109773. * @param options defines the options used to create the mesh
  109774. * @param scene defines the hosting scene
  109775. * @returns the ground mesh
  109776. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  109777. */
  109778. static CreateGround(name: string, options: {
  109779. width?: number;
  109780. height?: number;
  109781. subdivisions?: number;
  109782. subdivisionsX?: number;
  109783. subdivisionsY?: number;
  109784. updatable?: boolean;
  109785. }, scene?: Nullable<Scene>): Mesh;
  109786. /**
  109787. * Creates a tiled ground mesh
  109788. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  109789. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  109790. * * 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
  109791. * * 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
  109792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109793. * @param name defines the name of the mesh
  109794. * @param options defines the options used to create the mesh
  109795. * @param scene defines the hosting scene
  109796. * @returns the tiled ground mesh
  109797. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  109798. */
  109799. static CreateTiledGround(name: string, options: {
  109800. xmin: number;
  109801. zmin: number;
  109802. xmax: number;
  109803. zmax: number;
  109804. subdivisions?: {
  109805. w: number;
  109806. h: number;
  109807. };
  109808. precision?: {
  109809. w: number;
  109810. h: number;
  109811. };
  109812. updatable?: boolean;
  109813. }, scene?: Nullable<Scene>): Mesh;
  109814. /**
  109815. * Creates a ground mesh from a height map
  109816. * * The parameter `url` sets the URL of the height map image resource.
  109817. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  109818. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  109819. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  109820. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  109821. * * 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.
  109822. * * 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).
  109823. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109825. * @param name defines the name of the mesh
  109826. * @param url defines the url to the height map
  109827. * @param options defines the options used to create the mesh
  109828. * @param scene defines the hosting scene
  109829. * @returns the ground mesh
  109830. * @see https://doc.babylonjs.com/babylon101/height_map
  109831. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  109832. */
  109833. static CreateGroundFromHeightMap(name: string, url: string, options: {
  109834. width?: number;
  109835. height?: number;
  109836. subdivisions?: number;
  109837. minHeight?: number;
  109838. maxHeight?: number;
  109839. colorFilter?: Color3;
  109840. alphaFilter?: number;
  109841. updatable?: boolean;
  109842. onReady?: (mesh: GroundMesh) => void;
  109843. }, scene?: Nullable<Scene>): GroundMesh;
  109844. /**
  109845. * Creates a polygon mesh
  109846. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109847. * * 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
  109848. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109849. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109850. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109851. * * Remember you can only change the shape positions, not their number when updating a polygon
  109852. * @param name defines the name of the mesh
  109853. * @param options defines the options used to create the mesh
  109854. * @param scene defines the hosting scene
  109855. * @param earcutInjection can be used to inject your own earcut reference
  109856. * @returns the polygon mesh
  109857. */
  109858. static CreatePolygon(name: string, options: {
  109859. shape: Vector3[];
  109860. holes?: Vector3[][];
  109861. depth?: number;
  109862. faceUV?: Vector4[];
  109863. faceColors?: Color4[];
  109864. updatable?: boolean;
  109865. sideOrientation?: number;
  109866. frontUVs?: Vector4;
  109867. backUVs?: Vector4;
  109868. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109869. /**
  109870. * Creates an extruded polygon mesh, with depth in the Y direction.
  109871. * * 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)
  109872. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109873. * @param name defines the name of the mesh
  109874. * @param options defines the options used to create the mesh
  109875. * @param scene defines the hosting scene
  109876. * @param earcutInjection can be used to inject your own earcut reference
  109877. * @returns the polygon mesh
  109878. */
  109879. static ExtrudePolygon(name: string, options: {
  109880. shape: Vector3[];
  109881. holes?: Vector3[][];
  109882. depth?: number;
  109883. faceUV?: Vector4[];
  109884. faceColors?: Color4[];
  109885. updatable?: boolean;
  109886. sideOrientation?: number;
  109887. frontUVs?: Vector4;
  109888. backUVs?: Vector4;
  109889. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109890. /**
  109891. * Creates a tube mesh.
  109892. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109893. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109894. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109895. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109896. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109897. * * 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)
  109898. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109899. * * 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
  109900. * * 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
  109901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109903. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109904. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109905. * @param name defines the name of the mesh
  109906. * @param options defines the options used to create the mesh
  109907. * @param scene defines the hosting scene
  109908. * @returns the tube mesh
  109909. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109910. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109911. */
  109912. static CreateTube(name: string, options: {
  109913. path: Vector3[];
  109914. radius?: number;
  109915. tessellation?: number;
  109916. radiusFunction?: {
  109917. (i: number, distance: number): number;
  109918. };
  109919. cap?: number;
  109920. arc?: number;
  109921. updatable?: boolean;
  109922. sideOrientation?: number;
  109923. frontUVs?: Vector4;
  109924. backUVs?: Vector4;
  109925. instance?: Mesh;
  109926. invertUV?: boolean;
  109927. }, scene?: Nullable<Scene>): Mesh;
  109928. /**
  109929. * Creates a polyhedron mesh
  109930. * * 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
  109931. * * The parameter `size` (positive float, default 1) sets the polygon size
  109932. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109933. * * 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`
  109934. * * 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
  109935. * * 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)`)
  109936. * * 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
  109937. * * 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
  109938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109941. * @param name defines the name of the mesh
  109942. * @param options defines the options used to create the mesh
  109943. * @param scene defines the hosting scene
  109944. * @returns the polyhedron mesh
  109945. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  109946. */
  109947. static CreatePolyhedron(name: string, options: {
  109948. type?: number;
  109949. size?: number;
  109950. sizeX?: number;
  109951. sizeY?: number;
  109952. sizeZ?: number;
  109953. custom?: any;
  109954. faceUV?: Vector4[];
  109955. faceColors?: Color4[];
  109956. flat?: boolean;
  109957. updatable?: boolean;
  109958. sideOrientation?: number;
  109959. frontUVs?: Vector4;
  109960. backUVs?: Vector4;
  109961. }, scene?: Nullable<Scene>): Mesh;
  109962. /**
  109963. * Creates a decal mesh.
  109964. * 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
  109965. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109966. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109967. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109968. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109969. * @param name defines the name of the mesh
  109970. * @param sourceMesh defines the mesh where the decal must be applied
  109971. * @param options defines the options used to create the mesh
  109972. * @param scene defines the hosting scene
  109973. * @returns the decal mesh
  109974. * @see https://doc.babylonjs.com/how_to/decals
  109975. */
  109976. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109977. position?: Vector3;
  109978. normal?: Vector3;
  109979. size?: Vector3;
  109980. angle?: number;
  109981. }): Mesh;
  109982. }
  109983. }
  109984. declare module BABYLON {
  109985. /**
  109986. * A simplifier interface for future simplification implementations
  109987. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  109988. */
  109989. export interface ISimplifier {
  109990. /**
  109991. * Simplification of a given mesh according to the given settings.
  109992. * Since this requires computation, it is assumed that the function runs async.
  109993. * @param settings The settings of the simplification, including quality and distance
  109994. * @param successCallback A callback that will be called after the mesh was simplified.
  109995. * @param errorCallback in case of an error, this callback will be called. optional.
  109996. */
  109997. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  109998. }
  109999. /**
  110000. * Expected simplification settings.
  110001. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110002. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110003. */
  110004. export interface ISimplificationSettings {
  110005. /**
  110006. * Gets or sets the expected quality
  110007. */
  110008. quality: number;
  110009. /**
  110010. * Gets or sets the distance when this optimized version should be used
  110011. */
  110012. distance: number;
  110013. /**
  110014. * Gets an already optimized mesh
  110015. */
  110016. optimizeMesh?: boolean;
  110017. }
  110018. /**
  110019. * Class used to specify simplification options
  110020. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110021. */
  110022. export class SimplificationSettings implements ISimplificationSettings {
  110023. /** expected quality */
  110024. quality: number;
  110025. /** distance when this optimized version should be used */
  110026. distance: number;
  110027. /** already optimized mesh */
  110028. optimizeMesh?: boolean | undefined;
  110029. /**
  110030. * Creates a SimplificationSettings
  110031. * @param quality expected quality
  110032. * @param distance distance when this optimized version should be used
  110033. * @param optimizeMesh already optimized mesh
  110034. */
  110035. constructor(
  110036. /** expected quality */
  110037. quality: number,
  110038. /** distance when this optimized version should be used */
  110039. distance: number,
  110040. /** already optimized mesh */
  110041. optimizeMesh?: boolean | undefined);
  110042. }
  110043. /**
  110044. * Interface used to define a simplification task
  110045. */
  110046. export interface ISimplificationTask {
  110047. /**
  110048. * Array of settings
  110049. */
  110050. settings: Array<ISimplificationSettings>;
  110051. /**
  110052. * Simplification type
  110053. */
  110054. simplificationType: SimplificationType;
  110055. /**
  110056. * Mesh to simplify
  110057. */
  110058. mesh: Mesh;
  110059. /**
  110060. * Callback called on success
  110061. */
  110062. successCallback?: () => void;
  110063. /**
  110064. * Defines if parallel processing can be used
  110065. */
  110066. parallelProcessing: boolean;
  110067. }
  110068. /**
  110069. * Queue used to order the simplification tasks
  110070. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110071. */
  110072. export class SimplificationQueue {
  110073. private _simplificationArray;
  110074. /**
  110075. * Gets a boolean indicating that the process is still running
  110076. */
  110077. running: boolean;
  110078. /**
  110079. * Creates a new queue
  110080. */
  110081. constructor();
  110082. /**
  110083. * Adds a new simplification task
  110084. * @param task defines a task to add
  110085. */
  110086. addTask(task: ISimplificationTask): void;
  110087. /**
  110088. * Execute next task
  110089. */
  110090. executeNext(): void;
  110091. /**
  110092. * Execute a simplification task
  110093. * @param task defines the task to run
  110094. */
  110095. runSimplification(task: ISimplificationTask): void;
  110096. private getSimplifier;
  110097. }
  110098. /**
  110099. * The implemented types of simplification
  110100. * At the moment only Quadratic Error Decimation is implemented
  110101. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110102. */
  110103. export enum SimplificationType {
  110104. /** Quadratic error decimation */
  110105. QUADRATIC = 0
  110106. }
  110107. }
  110108. declare module BABYLON {
  110109. interface Scene {
  110110. /** @hidden (Backing field) */
  110111. _simplificationQueue: SimplificationQueue;
  110112. /**
  110113. * Gets or sets the simplification queue attached to the scene
  110114. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110115. */
  110116. simplificationQueue: SimplificationQueue;
  110117. }
  110118. interface Mesh {
  110119. /**
  110120. * Simplify the mesh according to the given array of settings.
  110121. * Function will return immediately and will simplify async
  110122. * @param settings a collection of simplification settings
  110123. * @param parallelProcessing should all levels calculate parallel or one after the other
  110124. * @param simplificationType the type of simplification to run
  110125. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110126. * @returns the current mesh
  110127. */
  110128. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110129. }
  110130. /**
  110131. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110132. * created in a scene
  110133. */
  110134. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110135. /**
  110136. * The component name helpfull to identify the component in the list of scene components.
  110137. */
  110138. readonly name: string;
  110139. /**
  110140. * The scene the component belongs to.
  110141. */
  110142. scene: Scene;
  110143. /**
  110144. * Creates a new instance of the component for the given scene
  110145. * @param scene Defines the scene to register the component in
  110146. */
  110147. constructor(scene: Scene);
  110148. /**
  110149. * Registers the component in a given scene
  110150. */
  110151. register(): void;
  110152. /**
  110153. * Rebuilds the elements related to this component in case of
  110154. * context lost for instance.
  110155. */
  110156. rebuild(): void;
  110157. /**
  110158. * Disposes the component and the associated ressources
  110159. */
  110160. dispose(): void;
  110161. private _beforeCameraUpdate;
  110162. }
  110163. }
  110164. declare module BABYLON {
  110165. /**
  110166. * Class used to enable access to IndexedDB
  110167. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110168. */
  110169. export class Database implements IOfflineProvider {
  110170. private _callbackManifestChecked;
  110171. private _currentSceneUrl;
  110172. private _db;
  110173. private _enableSceneOffline;
  110174. private _enableTexturesOffline;
  110175. private _manifestVersionFound;
  110176. private _mustUpdateRessources;
  110177. private _hasReachedQuota;
  110178. private _isSupported;
  110179. private _idbFactory;
  110180. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110181. private static IsUASupportingBlobStorage;
  110182. /**
  110183. * Gets a boolean indicating if Database storate is enabled (off by default)
  110184. */
  110185. static IDBStorageEnabled: boolean;
  110186. /**
  110187. * Gets a boolean indicating if scene must be saved in the database
  110188. */
  110189. readonly enableSceneOffline: boolean;
  110190. /**
  110191. * Gets a boolean indicating if textures must be saved in the database
  110192. */
  110193. readonly enableTexturesOffline: boolean;
  110194. /**
  110195. * Creates a new Database
  110196. * @param urlToScene defines the url to load the scene
  110197. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110198. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110199. */
  110200. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110201. private static _ParseURL;
  110202. private static _ReturnFullUrlLocation;
  110203. private _checkManifestFile;
  110204. /**
  110205. * Open the database and make it available
  110206. * @param successCallback defines the callback to call on success
  110207. * @param errorCallback defines the callback to call on error
  110208. */
  110209. open(successCallback: () => void, errorCallback: () => void): void;
  110210. /**
  110211. * Loads an image from the database
  110212. * @param url defines the url to load from
  110213. * @param image defines the target DOM image
  110214. */
  110215. loadImage(url: string, image: HTMLImageElement): void;
  110216. private _loadImageFromDBAsync;
  110217. private _saveImageIntoDBAsync;
  110218. private _checkVersionFromDB;
  110219. private _loadVersionFromDBAsync;
  110220. private _saveVersionIntoDBAsync;
  110221. /**
  110222. * Loads a file from database
  110223. * @param url defines the URL to load from
  110224. * @param sceneLoaded defines a callback to call on success
  110225. * @param progressCallBack defines a callback to call when progress changed
  110226. * @param errorCallback defines a callback to call on error
  110227. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110228. */
  110229. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110230. private _loadFileAsync;
  110231. private _saveFileAsync;
  110232. /**
  110233. * Validates if xhr data is correct
  110234. * @param xhr defines the request to validate
  110235. * @param dataType defines the expected data type
  110236. * @returns true if data is correct
  110237. */
  110238. private static _ValidateXHRData;
  110239. }
  110240. }
  110241. declare module BABYLON {
  110242. /** @hidden */
  110243. export var gpuUpdateParticlesPixelShader: {
  110244. name: string;
  110245. shader: string;
  110246. };
  110247. }
  110248. declare module BABYLON {
  110249. /** @hidden */
  110250. export var gpuUpdateParticlesVertexShader: {
  110251. name: string;
  110252. shader: string;
  110253. };
  110254. }
  110255. declare module BABYLON {
  110256. /** @hidden */
  110257. export var clipPlaneFragmentDeclaration2: {
  110258. name: string;
  110259. shader: string;
  110260. };
  110261. }
  110262. declare module BABYLON {
  110263. /** @hidden */
  110264. export var gpuRenderParticlesPixelShader: {
  110265. name: string;
  110266. shader: string;
  110267. };
  110268. }
  110269. declare module BABYLON {
  110270. /** @hidden */
  110271. export var clipPlaneVertexDeclaration2: {
  110272. name: string;
  110273. shader: string;
  110274. };
  110275. }
  110276. declare module BABYLON {
  110277. /** @hidden */
  110278. export var gpuRenderParticlesVertexShader: {
  110279. name: string;
  110280. shader: string;
  110281. };
  110282. }
  110283. declare module BABYLON {
  110284. /**
  110285. * This represents a GPU particle system in Babylon
  110286. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110287. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110288. */
  110289. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110290. /**
  110291. * The layer mask we are rendering the particles through.
  110292. */
  110293. layerMask: number;
  110294. private _capacity;
  110295. private _activeCount;
  110296. private _currentActiveCount;
  110297. private _accumulatedCount;
  110298. private _renderEffect;
  110299. private _updateEffect;
  110300. private _buffer0;
  110301. private _buffer1;
  110302. private _spriteBuffer;
  110303. private _updateVAO;
  110304. private _renderVAO;
  110305. private _targetIndex;
  110306. private _sourceBuffer;
  110307. private _targetBuffer;
  110308. private _engine;
  110309. private _currentRenderId;
  110310. private _started;
  110311. private _stopped;
  110312. private _timeDelta;
  110313. private _randomTexture;
  110314. private _randomTexture2;
  110315. private _attributesStrideSize;
  110316. private _updateEffectOptions;
  110317. private _randomTextureSize;
  110318. private _actualFrame;
  110319. private readonly _rawTextureWidth;
  110320. /**
  110321. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110322. */
  110323. static readonly IsSupported: boolean;
  110324. /**
  110325. * An event triggered when the system is disposed.
  110326. */
  110327. onDisposeObservable: Observable<GPUParticleSystem>;
  110328. /**
  110329. * Gets the maximum number of particles active at the same time.
  110330. * @returns The max number of active particles.
  110331. */
  110332. getCapacity(): number;
  110333. /**
  110334. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110335. * to override the particles.
  110336. */
  110337. forceDepthWrite: boolean;
  110338. /**
  110339. * Gets or set the number of active particles
  110340. */
  110341. activeParticleCount: number;
  110342. private _preWarmDone;
  110343. /**
  110344. * Is this system ready to be used/rendered
  110345. * @return true if the system is ready
  110346. */
  110347. isReady(): boolean;
  110348. /**
  110349. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110350. * @returns True if it has been started, otherwise false.
  110351. */
  110352. isStarted(): boolean;
  110353. /**
  110354. * Starts the particle system and begins to emit
  110355. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110356. */
  110357. start(delay?: number): void;
  110358. /**
  110359. * Stops the particle system.
  110360. */
  110361. stop(): void;
  110362. /**
  110363. * Remove all active particles
  110364. */
  110365. reset(): void;
  110366. /**
  110367. * Returns the string "GPUParticleSystem"
  110368. * @returns a string containing the class name
  110369. */
  110370. getClassName(): string;
  110371. private _colorGradientsTexture;
  110372. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110373. /**
  110374. * Adds a new color gradient
  110375. * @param gradient defines the gradient to use (between 0 and 1)
  110376. * @param color1 defines the color to affect to the specified gradient
  110377. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110378. * @returns the current particle system
  110379. */
  110380. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110381. /**
  110382. * Remove a specific color gradient
  110383. * @param gradient defines the gradient to remove
  110384. * @returns the current particle system
  110385. */
  110386. removeColorGradient(gradient: number): GPUParticleSystem;
  110387. private _angularSpeedGradientsTexture;
  110388. private _sizeGradientsTexture;
  110389. private _velocityGradientsTexture;
  110390. private _limitVelocityGradientsTexture;
  110391. private _dragGradientsTexture;
  110392. private _addFactorGradient;
  110393. /**
  110394. * Adds a new size gradient
  110395. * @param gradient defines the gradient to use (between 0 and 1)
  110396. * @param factor defines the size factor to affect to the specified gradient
  110397. * @returns the current particle system
  110398. */
  110399. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110400. /**
  110401. * Remove a specific size gradient
  110402. * @param gradient defines the gradient to remove
  110403. * @returns the current particle system
  110404. */
  110405. removeSizeGradient(gradient: number): GPUParticleSystem;
  110406. /**
  110407. * Adds a new angular speed gradient
  110408. * @param gradient defines the gradient to use (between 0 and 1)
  110409. * @param factor defines the angular speed to affect to the specified gradient
  110410. * @returns the current particle system
  110411. */
  110412. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110413. /**
  110414. * Remove a specific angular speed gradient
  110415. * @param gradient defines the gradient to remove
  110416. * @returns the current particle system
  110417. */
  110418. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110419. /**
  110420. * Adds a new velocity gradient
  110421. * @param gradient defines the gradient to use (between 0 and 1)
  110422. * @param factor defines the velocity to affect to the specified gradient
  110423. * @returns the current particle system
  110424. */
  110425. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110426. /**
  110427. * Remove a specific velocity gradient
  110428. * @param gradient defines the gradient to remove
  110429. * @returns the current particle system
  110430. */
  110431. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110432. /**
  110433. * Adds a new limit velocity gradient
  110434. * @param gradient defines the gradient to use (between 0 and 1)
  110435. * @param factor defines the limit velocity value to affect to the specified gradient
  110436. * @returns the current particle system
  110437. */
  110438. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110439. /**
  110440. * Remove a specific limit velocity gradient
  110441. * @param gradient defines the gradient to remove
  110442. * @returns the current particle system
  110443. */
  110444. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110445. /**
  110446. * Adds a new drag gradient
  110447. * @param gradient defines the gradient to use (between 0 and 1)
  110448. * @param factor defines the drag value to affect to the specified gradient
  110449. * @returns the current particle system
  110450. */
  110451. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110452. /**
  110453. * Remove a specific drag gradient
  110454. * @param gradient defines the gradient to remove
  110455. * @returns the current particle system
  110456. */
  110457. removeDragGradient(gradient: number): GPUParticleSystem;
  110458. /**
  110459. * Not supported by GPUParticleSystem
  110460. * @param gradient defines the gradient to use (between 0 and 1)
  110461. * @param factor defines the emit rate value to affect to the specified gradient
  110462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110463. * @returns the current particle system
  110464. */
  110465. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110466. /**
  110467. * Not supported by GPUParticleSystem
  110468. * @param gradient defines the gradient to remove
  110469. * @returns the current particle system
  110470. */
  110471. removeEmitRateGradient(gradient: number): IParticleSystem;
  110472. /**
  110473. * Not supported by GPUParticleSystem
  110474. * @param gradient defines the gradient to use (between 0 and 1)
  110475. * @param factor defines the start size value to affect to the specified gradient
  110476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110477. * @returns the current particle system
  110478. */
  110479. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110480. /**
  110481. * Not supported by GPUParticleSystem
  110482. * @param gradient defines the gradient to remove
  110483. * @returns the current particle system
  110484. */
  110485. removeStartSizeGradient(gradient: number): IParticleSystem;
  110486. /**
  110487. * Not supported by GPUParticleSystem
  110488. * @param gradient defines the gradient to use (between 0 and 1)
  110489. * @param min defines the color remap minimal range
  110490. * @param max defines the color remap maximal range
  110491. * @returns the current particle system
  110492. */
  110493. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110494. /**
  110495. * Not supported by GPUParticleSystem
  110496. * @param gradient defines the gradient to remove
  110497. * @returns the current particle system
  110498. */
  110499. removeColorRemapGradient(): IParticleSystem;
  110500. /**
  110501. * Not supported by GPUParticleSystem
  110502. * @param gradient defines the gradient to use (between 0 and 1)
  110503. * @param min defines the alpha remap minimal range
  110504. * @param max defines the alpha remap maximal range
  110505. * @returns the current particle system
  110506. */
  110507. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110508. /**
  110509. * Not supported by GPUParticleSystem
  110510. * @param gradient defines the gradient to remove
  110511. * @returns the current particle system
  110512. */
  110513. removeAlphaRemapGradient(): IParticleSystem;
  110514. /**
  110515. * Not supported by GPUParticleSystem
  110516. * @param gradient defines the gradient to use (between 0 and 1)
  110517. * @param color defines the color to affect to the specified gradient
  110518. * @returns the current particle system
  110519. */
  110520. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110521. /**
  110522. * Not supported by GPUParticleSystem
  110523. * @param gradient defines the gradient to remove
  110524. * @returns the current particle system
  110525. */
  110526. removeRampGradient(): IParticleSystem;
  110527. /**
  110528. * Not supported by GPUParticleSystem
  110529. * @returns the list of ramp gradients
  110530. */
  110531. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110532. /**
  110533. * Not supported by GPUParticleSystem
  110534. * Gets or sets a boolean indicating that ramp gradients must be used
  110535. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110536. */
  110537. useRampGradients: boolean;
  110538. /**
  110539. * Not supported by GPUParticleSystem
  110540. * @param gradient defines the gradient to use (between 0 and 1)
  110541. * @param factor defines the life time factor to affect to the specified gradient
  110542. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110543. * @returns the current particle system
  110544. */
  110545. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110546. /**
  110547. * Not supported by GPUParticleSystem
  110548. * @param gradient defines the gradient to remove
  110549. * @returns the current particle system
  110550. */
  110551. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110552. /**
  110553. * Instantiates a GPU particle system.
  110554. * 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.
  110555. * @param name The name of the particle system
  110556. * @param options The options used to create the system
  110557. * @param scene The scene the particle system belongs to
  110558. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110559. */
  110560. constructor(name: string, options: Partial<{
  110561. capacity: number;
  110562. randomTextureSize: number;
  110563. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110564. protected _reset(): void;
  110565. private _createUpdateVAO;
  110566. private _createRenderVAO;
  110567. private _initialize;
  110568. /** @hidden */
  110569. _recreateUpdateEffect(): void;
  110570. /** @hidden */
  110571. _recreateRenderEffect(): void;
  110572. /**
  110573. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110574. * @param preWarm defines if we are in the pre-warmimg phase
  110575. */
  110576. animate(preWarm?: boolean): void;
  110577. private _createFactorGradientTexture;
  110578. private _createSizeGradientTexture;
  110579. private _createAngularSpeedGradientTexture;
  110580. private _createVelocityGradientTexture;
  110581. private _createLimitVelocityGradientTexture;
  110582. private _createDragGradientTexture;
  110583. private _createColorGradientTexture;
  110584. /**
  110585. * Renders the particle system in its current state
  110586. * @param preWarm defines if the system should only update the particles but not render them
  110587. * @returns the current number of particles
  110588. */
  110589. render(preWarm?: boolean): number;
  110590. /**
  110591. * Rebuilds the particle system
  110592. */
  110593. rebuild(): void;
  110594. private _releaseBuffers;
  110595. private _releaseVAOs;
  110596. /**
  110597. * Disposes the particle system and free the associated resources
  110598. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110599. */
  110600. dispose(disposeTexture?: boolean): void;
  110601. /**
  110602. * Clones the particle system.
  110603. * @param name The name of the cloned object
  110604. * @param newEmitter The new emitter to use
  110605. * @returns the cloned particle system
  110606. */
  110607. clone(name: string, newEmitter: any): GPUParticleSystem;
  110608. /**
  110609. * Serializes the particle system to a JSON object.
  110610. * @returns the JSON object
  110611. */
  110612. serialize(): any;
  110613. /**
  110614. * Parses a JSON object to create a GPU particle system.
  110615. * @param parsedParticleSystem The JSON object to parse
  110616. * @param scene The scene to create the particle system in
  110617. * @param rootUrl The root url to use to load external dependencies like texture
  110618. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110619. * @returns the parsed GPU particle system
  110620. */
  110621. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110622. }
  110623. }
  110624. declare module BABYLON {
  110625. /**
  110626. * Represents a set of particle systems working together to create a specific effect
  110627. */
  110628. export class ParticleSystemSet implements IDisposable {
  110629. private _emitterCreationOptions;
  110630. private _emitterNode;
  110631. /**
  110632. * Gets the particle system list
  110633. */
  110634. systems: IParticleSystem[];
  110635. /**
  110636. * Gets the emitter node used with this set
  110637. */
  110638. readonly emitterNode: Nullable<TransformNode>;
  110639. /**
  110640. * Creates a new emitter mesh as a sphere
  110641. * @param options defines the options used to create the sphere
  110642. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110643. * @param scene defines the hosting scene
  110644. */
  110645. setEmitterAsSphere(options: {
  110646. diameter: number;
  110647. segments: number;
  110648. color: Color3;
  110649. }, renderingGroupId: number, scene: Scene): void;
  110650. /**
  110651. * Starts all particle systems of the set
  110652. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110653. */
  110654. start(emitter?: AbstractMesh): void;
  110655. /**
  110656. * Release all associated resources
  110657. */
  110658. dispose(): void;
  110659. /**
  110660. * Serialize the set into a JSON compatible object
  110661. * @returns a JSON compatible representation of the set
  110662. */
  110663. serialize(): any;
  110664. /**
  110665. * Parse a new ParticleSystemSet from a serialized source
  110666. * @param data defines a JSON compatible representation of the set
  110667. * @param scene defines the hosting scene
  110668. * @param gpu defines if we want GPU particles or CPU particles
  110669. * @returns a new ParticleSystemSet
  110670. */
  110671. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110672. }
  110673. }
  110674. declare module BABYLON {
  110675. /**
  110676. * This class is made for on one-liner static method to help creating particle system set.
  110677. */
  110678. export class ParticleHelper {
  110679. /**
  110680. * Gets or sets base Assets URL
  110681. */
  110682. static BaseAssetsUrl: string;
  110683. /**
  110684. * Create a default particle system that you can tweak
  110685. * @param emitter defines the emitter to use
  110686. * @param capacity defines the system capacity (default is 500 particles)
  110687. * @param scene defines the hosting scene
  110688. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110689. * @returns the new Particle system
  110690. */
  110691. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110692. /**
  110693. * This is the main static method (one-liner) of this helper to create different particle systems
  110694. * @param type This string represents the type to the particle system to create
  110695. * @param scene The scene where the particle system should live
  110696. * @param gpu If the system will use gpu
  110697. * @returns the ParticleSystemSet created
  110698. */
  110699. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110700. /**
  110701. * Static function used to export a particle system to a ParticleSystemSet variable.
  110702. * Please note that the emitter shape is not exported
  110703. * @param systems defines the particle systems to export
  110704. * @returns the created particle system set
  110705. */
  110706. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110707. }
  110708. }
  110709. declare module BABYLON {
  110710. interface Engine {
  110711. /**
  110712. * Create an effect to use with particle systems.
  110713. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110714. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110715. * @param uniformsNames defines a list of attribute names
  110716. * @param samplers defines an array of string used to represent textures
  110717. * @param defines defines the string containing the defines to use to compile the shaders
  110718. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110719. * @param onCompiled defines a function to call when the effect creation is successful
  110720. * @param onError defines a function to call when the effect creation has failed
  110721. * @returns the new Effect
  110722. */
  110723. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110724. }
  110725. interface Mesh {
  110726. /**
  110727. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110728. * @returns an array of IParticleSystem
  110729. */
  110730. getEmittedParticleSystems(): IParticleSystem[];
  110731. /**
  110732. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110733. * @returns an array of IParticleSystem
  110734. */
  110735. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110736. }
  110737. /**
  110738. * @hidden
  110739. */
  110740. export var _IDoNeedToBeInTheBuild: number;
  110741. }
  110742. declare module BABYLON {
  110743. interface Scene {
  110744. /** @hidden (Backing field) */
  110745. _physicsEngine: Nullable<IPhysicsEngine>;
  110746. /**
  110747. * Gets the current physics engine
  110748. * @returns a IPhysicsEngine or null if none attached
  110749. */
  110750. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  110751. /**
  110752. * Enables physics to the current scene
  110753. * @param gravity defines the scene's gravity for the physics engine
  110754. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  110755. * @return a boolean indicating if the physics engine was initialized
  110756. */
  110757. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  110758. /**
  110759. * Disables and disposes the physics engine associated with the scene
  110760. */
  110761. disablePhysicsEngine(): void;
  110762. /**
  110763. * Gets a boolean indicating if there is an active physics engine
  110764. * @returns a boolean indicating if there is an active physics engine
  110765. */
  110766. isPhysicsEnabled(): boolean;
  110767. /**
  110768. * Deletes a physics compound impostor
  110769. * @param compound defines the compound to delete
  110770. */
  110771. deleteCompoundImpostor(compound: any): void;
  110772. /**
  110773. * An event triggered when physic simulation is about to be run
  110774. */
  110775. onBeforePhysicsObservable: Observable<Scene>;
  110776. /**
  110777. * An event triggered when physic simulation has been done
  110778. */
  110779. onAfterPhysicsObservable: Observable<Scene>;
  110780. }
  110781. interface AbstractMesh {
  110782. /** @hidden */
  110783. _physicsImpostor: Nullable<PhysicsImpostor>;
  110784. /**
  110785. * Gets or sets impostor used for physic simulation
  110786. * @see http://doc.babylonjs.com/features/physics_engine
  110787. */
  110788. physicsImpostor: Nullable<PhysicsImpostor>;
  110789. /**
  110790. * Gets the current physics impostor
  110791. * @see http://doc.babylonjs.com/features/physics_engine
  110792. * @returns a physics impostor or null
  110793. */
  110794. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  110795. /** Apply a physic impulse to the mesh
  110796. * @param force defines the force to apply
  110797. * @param contactPoint defines where to apply the force
  110798. * @returns the current mesh
  110799. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110800. */
  110801. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  110802. /**
  110803. * Creates a physic joint between two meshes
  110804. * @param otherMesh defines the other mesh to use
  110805. * @param pivot1 defines the pivot to use on this mesh
  110806. * @param pivot2 defines the pivot to use on the other mesh
  110807. * @param options defines additional options (can be plugin dependent)
  110808. * @returns the current mesh
  110809. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  110810. */
  110811. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  110812. /** @hidden */
  110813. _disposePhysicsObserver: Nullable<Observer<Node>>;
  110814. }
  110815. /**
  110816. * Defines the physics engine scene component responsible to manage a physics engine
  110817. */
  110818. export class PhysicsEngineSceneComponent implements ISceneComponent {
  110819. /**
  110820. * The component name helpful to identify the component in the list of scene components.
  110821. */
  110822. readonly name: string;
  110823. /**
  110824. * The scene the component belongs to.
  110825. */
  110826. scene: Scene;
  110827. /**
  110828. * Creates a new instance of the component for the given scene
  110829. * @param scene Defines the scene to register the component in
  110830. */
  110831. constructor(scene: Scene);
  110832. /**
  110833. * Registers the component in a given scene
  110834. */
  110835. register(): void;
  110836. /**
  110837. * Rebuilds the elements related to this component in case of
  110838. * context lost for instance.
  110839. */
  110840. rebuild(): void;
  110841. /**
  110842. * Disposes the component and the associated ressources
  110843. */
  110844. dispose(): void;
  110845. }
  110846. }
  110847. declare module BABYLON {
  110848. /**
  110849. * A helper for physics simulations
  110850. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  110851. */
  110852. export class PhysicsHelper {
  110853. private _scene;
  110854. private _physicsEngine;
  110855. /**
  110856. * Initializes the Physics helper
  110857. * @param scene Babylon.js scene
  110858. */
  110859. constructor(scene: Scene);
  110860. /**
  110861. * Applies a radial explosion impulse
  110862. * @param origin the origin of the explosion
  110863. * @param radiusOrEventOptions the radius or the options of radial explosion
  110864. * @param strength the explosion strength
  110865. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110866. * @returns A physics radial explosion event, or null
  110867. */
  110868. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110869. /**
  110870. * Applies a radial explosion force
  110871. * @param origin the origin of the explosion
  110872. * @param radiusOrEventOptions the radius or the options of radial explosion
  110873. * @param strength the explosion strength
  110874. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110875. * @returns A physics radial explosion event, or null
  110876. */
  110877. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  110878. /**
  110879. * Creates a gravitational field
  110880. * @param origin the origin of the explosion
  110881. * @param radiusOrEventOptions the radius or the options of radial explosion
  110882. * @param strength the explosion strength
  110883. * @param falloff possible options: Constant & Linear. Defaults to Constant
  110884. * @returns A physics gravitational field event, or null
  110885. */
  110886. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  110887. /**
  110888. * Creates a physics updraft event
  110889. * @param origin the origin of the updraft
  110890. * @param radiusOrEventOptions the radius or the options of the updraft
  110891. * @param strength the strength of the updraft
  110892. * @param height the height of the updraft
  110893. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  110894. * @returns A physics updraft event, or null
  110895. */
  110896. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  110897. /**
  110898. * Creates a physics vortex event
  110899. * @param origin the of the vortex
  110900. * @param radiusOrEventOptions the radius or the options of the vortex
  110901. * @param strength the strength of the vortex
  110902. * @param height the height of the vortex
  110903. * @returns a Physics vortex event, or null
  110904. * A physics vortex event or null
  110905. */
  110906. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  110907. }
  110908. /**
  110909. * Represents a physics radial explosion event
  110910. */
  110911. class PhysicsRadialExplosionEvent {
  110912. private _scene;
  110913. private _options;
  110914. private _sphere;
  110915. private _dataFetched;
  110916. /**
  110917. * Initializes a radial explosioin event
  110918. * @param _scene BabylonJS scene
  110919. * @param _options The options for the vortex event
  110920. */
  110921. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  110922. /**
  110923. * Returns the data related to the radial explosion event (sphere).
  110924. * @returns The radial explosion event data
  110925. */
  110926. getData(): PhysicsRadialExplosionEventData;
  110927. /**
  110928. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  110929. * @param impostor A physics imposter
  110930. * @param origin the origin of the explosion
  110931. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  110932. */
  110933. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  110934. /**
  110935. * Triggers affecterd impostors callbacks
  110936. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  110937. */
  110938. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  110939. /**
  110940. * Disposes the sphere.
  110941. * @param force Specifies if the sphere should be disposed by force
  110942. */
  110943. dispose(force?: boolean): void;
  110944. /*** Helpers ***/
  110945. private _prepareSphere;
  110946. private _intersectsWithSphere;
  110947. }
  110948. /**
  110949. * Represents a gravitational field event
  110950. */
  110951. class PhysicsGravitationalFieldEvent {
  110952. private _physicsHelper;
  110953. private _scene;
  110954. private _origin;
  110955. private _options;
  110956. private _tickCallback;
  110957. private _sphere;
  110958. private _dataFetched;
  110959. /**
  110960. * Initializes the physics gravitational field event
  110961. * @param _physicsHelper A physics helper
  110962. * @param _scene BabylonJS scene
  110963. * @param _origin The origin position of the gravitational field event
  110964. * @param _options The options for the vortex event
  110965. */
  110966. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  110967. /**
  110968. * Returns the data related to the gravitational field event (sphere).
  110969. * @returns A gravitational field event
  110970. */
  110971. getData(): PhysicsGravitationalFieldEventData;
  110972. /**
  110973. * Enables the gravitational field.
  110974. */
  110975. enable(): void;
  110976. /**
  110977. * Disables the gravitational field.
  110978. */
  110979. disable(): void;
  110980. /**
  110981. * Disposes the sphere.
  110982. * @param force The force to dispose from the gravitational field event
  110983. */
  110984. dispose(force?: boolean): void;
  110985. private _tick;
  110986. }
  110987. /**
  110988. * Represents a physics updraft event
  110989. */
  110990. class PhysicsUpdraftEvent {
  110991. private _scene;
  110992. private _origin;
  110993. private _options;
  110994. private _physicsEngine;
  110995. private _originTop;
  110996. private _originDirection;
  110997. private _tickCallback;
  110998. private _cylinder;
  110999. private _cylinderPosition;
  111000. private _dataFetched;
  111001. /**
  111002. * Initializes the physics updraft event
  111003. * @param _scene BabylonJS scene
  111004. * @param _origin The origin position of the updraft
  111005. * @param _options The options for the updraft event
  111006. */
  111007. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111008. /**
  111009. * Returns the data related to the updraft event (cylinder).
  111010. * @returns A physics updraft event
  111011. */
  111012. getData(): PhysicsUpdraftEventData;
  111013. /**
  111014. * Enables the updraft.
  111015. */
  111016. enable(): void;
  111017. /**
  111018. * Disables the updraft.
  111019. */
  111020. disable(): void;
  111021. /**
  111022. * Disposes the cylinder.
  111023. * @param force Specifies if the updraft should be disposed by force
  111024. */
  111025. dispose(force?: boolean): void;
  111026. private getImpostorHitData;
  111027. private _tick;
  111028. /*** Helpers ***/
  111029. private _prepareCylinder;
  111030. private _intersectsWithCylinder;
  111031. }
  111032. /**
  111033. * Represents a physics vortex event
  111034. */
  111035. class PhysicsVortexEvent {
  111036. private _scene;
  111037. private _origin;
  111038. private _options;
  111039. private _physicsEngine;
  111040. private _originTop;
  111041. private _tickCallback;
  111042. private _cylinder;
  111043. private _cylinderPosition;
  111044. private _dataFetched;
  111045. /**
  111046. * Initializes the physics vortex event
  111047. * @param _scene The BabylonJS scene
  111048. * @param _origin The origin position of the vortex
  111049. * @param _options The options for the vortex event
  111050. */
  111051. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111052. /**
  111053. * Returns the data related to the vortex event (cylinder).
  111054. * @returns The physics vortex event data
  111055. */
  111056. getData(): PhysicsVortexEventData;
  111057. /**
  111058. * Enables the vortex.
  111059. */
  111060. enable(): void;
  111061. /**
  111062. * Disables the cortex.
  111063. */
  111064. disable(): void;
  111065. /**
  111066. * Disposes the sphere.
  111067. * @param force
  111068. */
  111069. dispose(force?: boolean): void;
  111070. private getImpostorHitData;
  111071. private _tick;
  111072. /*** Helpers ***/
  111073. private _prepareCylinder;
  111074. private _intersectsWithCylinder;
  111075. }
  111076. /**
  111077. * Options fot the radial explosion event
  111078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111079. */
  111080. export class PhysicsRadialExplosionEventOptions {
  111081. /**
  111082. * The radius of the sphere for the radial explosion.
  111083. */
  111084. radius: number;
  111085. /**
  111086. * The strenth of the explosion.
  111087. */
  111088. strength: number;
  111089. /**
  111090. * The strenght of the force in correspondence to the distance of the affected object
  111091. */
  111092. falloff: PhysicsRadialImpulseFalloff;
  111093. /**
  111094. * Sphere options for the radial explosion.
  111095. */
  111096. sphere: {
  111097. segments: number;
  111098. diameter: number;
  111099. };
  111100. /**
  111101. * Sphere options for the radial explosion.
  111102. */
  111103. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111104. }
  111105. /**
  111106. * Options fot the updraft event
  111107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111108. */
  111109. export class PhysicsUpdraftEventOptions {
  111110. /**
  111111. * The radius of the cylinder for the vortex
  111112. */
  111113. radius: number;
  111114. /**
  111115. * The strenth of the updraft.
  111116. */
  111117. strength: number;
  111118. /**
  111119. * The height of the cylinder for the updraft.
  111120. */
  111121. height: number;
  111122. /**
  111123. * The mode for the the updraft.
  111124. */
  111125. updraftMode: PhysicsUpdraftMode;
  111126. }
  111127. /**
  111128. * Options fot the vortex event
  111129. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111130. */
  111131. export class PhysicsVortexEventOptions {
  111132. /**
  111133. * The radius of the cylinder for the vortex
  111134. */
  111135. radius: number;
  111136. /**
  111137. * The strenth of the vortex.
  111138. */
  111139. strength: number;
  111140. /**
  111141. * The height of the cylinder for the vortex.
  111142. */
  111143. height: number;
  111144. /**
  111145. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111146. */
  111147. centripetalForceThreshold: number;
  111148. /**
  111149. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111150. */
  111151. centripetalForceMultiplier: number;
  111152. /**
  111153. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111154. */
  111155. centrifugalForceMultiplier: number;
  111156. /**
  111157. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111158. */
  111159. updraftForceMultiplier: number;
  111160. }
  111161. /**
  111162. * The strenght of the force in correspondence to the distance of the affected object
  111163. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111164. */
  111165. export enum PhysicsRadialImpulseFalloff {
  111166. /** Defines that impulse is constant in strength across it's whole radius */
  111167. Constant = 0,
  111168. /** Defines that impulse gets weaker if it's further from the origin */
  111169. Linear = 1
  111170. }
  111171. /**
  111172. * The strength of the force in correspondence to the distance of the affected object
  111173. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111174. */
  111175. export enum PhysicsUpdraftMode {
  111176. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111177. Center = 0,
  111178. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111179. Perpendicular = 1
  111180. }
  111181. /**
  111182. * Interface for a physics hit data
  111183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111184. */
  111185. export interface PhysicsHitData {
  111186. /**
  111187. * The force applied at the contact point
  111188. */
  111189. force: Vector3;
  111190. /**
  111191. * The contact point
  111192. */
  111193. contactPoint: Vector3;
  111194. /**
  111195. * The distance from the origin to the contact point
  111196. */
  111197. distanceFromOrigin: number;
  111198. }
  111199. /**
  111200. * Interface for radial explosion event data
  111201. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111202. */
  111203. export interface PhysicsRadialExplosionEventData {
  111204. /**
  111205. * A sphere used for the radial explosion event
  111206. */
  111207. sphere: Mesh;
  111208. }
  111209. /**
  111210. * Interface for gravitational field event data
  111211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111212. */
  111213. export interface PhysicsGravitationalFieldEventData {
  111214. /**
  111215. * A sphere mesh used for the gravitational field event
  111216. */
  111217. sphere: Mesh;
  111218. }
  111219. /**
  111220. * Interface for updraft event data
  111221. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111222. */
  111223. export interface PhysicsUpdraftEventData {
  111224. /**
  111225. * A cylinder used for the updraft event
  111226. */
  111227. cylinder: Mesh;
  111228. }
  111229. /**
  111230. * Interface for vortex event data
  111231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111232. */
  111233. export interface PhysicsVortexEventData {
  111234. /**
  111235. * A cylinder used for the vortex event
  111236. */
  111237. cylinder: Mesh;
  111238. }
  111239. /**
  111240. * Interface for an affected physics impostor
  111241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111242. */
  111243. export interface PhysicsAffectedImpostorWithData {
  111244. /**
  111245. * The impostor affected by the effect
  111246. */
  111247. impostor: PhysicsImpostor;
  111248. /**
  111249. * The data about the hit/horce from the explosion
  111250. */
  111251. hitData: PhysicsHitData;
  111252. }
  111253. }
  111254. declare module BABYLON {
  111255. /** @hidden */
  111256. export var blackAndWhitePixelShader: {
  111257. name: string;
  111258. shader: string;
  111259. };
  111260. }
  111261. declare module BABYLON {
  111262. /**
  111263. * Post process used to render in black and white
  111264. */
  111265. export class BlackAndWhitePostProcess extends PostProcess {
  111266. /**
  111267. * Linear about to convert he result to black and white (default: 1)
  111268. */
  111269. degree: number;
  111270. /**
  111271. * Creates a black and white post process
  111272. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111273. * @param name The name of the effect.
  111274. * @param options The required width/height ratio to downsize to before computing the render pass.
  111275. * @param camera The camera to apply the render pass to.
  111276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111277. * @param engine The engine which the post process will be applied. (default: current engine)
  111278. * @param reusable If the post process can be reused on the same frame. (default: false)
  111279. */
  111280. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111281. }
  111282. }
  111283. declare module BABYLON {
  111284. /**
  111285. * This represents a set of one or more post processes in Babylon.
  111286. * A post process can be used to apply a shader to a texture after it is rendered.
  111287. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111288. */
  111289. export class PostProcessRenderEffect {
  111290. private _postProcesses;
  111291. private _getPostProcesses;
  111292. private _singleInstance;
  111293. private _cameras;
  111294. private _indicesForCamera;
  111295. /**
  111296. * Name of the effect
  111297. * @hidden
  111298. */
  111299. _name: string;
  111300. /**
  111301. * Instantiates a post process render effect.
  111302. * A post process can be used to apply a shader to a texture after it is rendered.
  111303. * @param engine The engine the effect is tied to
  111304. * @param name The name of the effect
  111305. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111306. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111307. */
  111308. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111309. /**
  111310. * Checks if all the post processes in the effect are supported.
  111311. */
  111312. readonly isSupported: boolean;
  111313. /**
  111314. * Updates the current state of the effect
  111315. * @hidden
  111316. */
  111317. _update(): 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. * Attaches the effect on cameras
  111326. * @param cameras The camera to attach to.
  111327. * @hidden
  111328. */
  111329. _attachCameras(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. * Detatches the effect on cameras
  111338. * @param cameras The camera to detatch from.
  111339. * @hidden
  111340. */
  111341. _detachCameras(cameras: Camera[]): void;
  111342. /**
  111343. * Enables the effect on given cameras
  111344. * @param cameras The camera to enable.
  111345. * @hidden
  111346. */
  111347. _enable(cameras: Camera): void;
  111348. /**
  111349. * Enables the effect on given cameras
  111350. * @param cameras The camera to enable.
  111351. * @hidden
  111352. */
  111353. _enable(cameras: Nullable<Camera[]>): void;
  111354. /**
  111355. * Disables the effect on the given cameras
  111356. * @param cameras The camera to disable.
  111357. * @hidden
  111358. */
  111359. _disable(cameras: Camera): void;
  111360. /**
  111361. * Disables the effect on the given cameras
  111362. * @param cameras The camera to disable.
  111363. * @hidden
  111364. */
  111365. _disable(cameras: Nullable<Camera[]>): void;
  111366. /**
  111367. * Gets a list of the post processes contained in the effect.
  111368. * @param camera The camera to get the post processes on.
  111369. * @returns The list of the post processes in the effect.
  111370. */
  111371. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111372. }
  111373. }
  111374. declare module BABYLON {
  111375. /** @hidden */
  111376. export var extractHighlightsPixelShader: {
  111377. name: string;
  111378. shader: string;
  111379. };
  111380. }
  111381. declare module BABYLON {
  111382. /**
  111383. * 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.
  111384. */
  111385. export class ExtractHighlightsPostProcess extends PostProcess {
  111386. /**
  111387. * The luminance threshold, pixels below this value will be set to black.
  111388. */
  111389. threshold: number;
  111390. /** @hidden */
  111391. _exposure: number;
  111392. /**
  111393. * Post process which has the input texture to be used when performing highlight extraction
  111394. * @hidden
  111395. */
  111396. _inputPostProcess: Nullable<PostProcess>;
  111397. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111398. }
  111399. }
  111400. declare module BABYLON {
  111401. /** @hidden */
  111402. export var bloomMergePixelShader: {
  111403. name: string;
  111404. shader: string;
  111405. };
  111406. }
  111407. declare module BABYLON {
  111408. /**
  111409. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111410. */
  111411. export class BloomMergePostProcess extends PostProcess {
  111412. /** Weight of the bloom to be added to the original input. */
  111413. weight: number;
  111414. /**
  111415. * Creates a new instance of @see BloomMergePostProcess
  111416. * @param name The name of the effect.
  111417. * @param originalFromInput Post process which's input will be used for the merge.
  111418. * @param blurred Blurred highlights post process which's output will be used.
  111419. * @param weight Weight of the bloom to be added to the original input.
  111420. * @param options The required width/height ratio to downsize to before computing the render pass.
  111421. * @param camera The camera to apply the render pass to.
  111422. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111423. * @param engine The engine which the post process will be applied. (default: current engine)
  111424. * @param reusable If the post process can be reused on the same frame. (default: false)
  111425. * @param textureType Type of textures used when performing the post process. (default: 0)
  111426. * @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)
  111427. */
  111428. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111429. /** Weight of the bloom to be added to the original input. */
  111430. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111431. }
  111432. }
  111433. declare module BABYLON {
  111434. /**
  111435. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111436. */
  111437. export class BloomEffect extends PostProcessRenderEffect {
  111438. private bloomScale;
  111439. /**
  111440. * @hidden Internal
  111441. */
  111442. _effects: Array<PostProcess>;
  111443. /**
  111444. * @hidden Internal
  111445. */
  111446. _downscale: ExtractHighlightsPostProcess;
  111447. private _blurX;
  111448. private _blurY;
  111449. private _merge;
  111450. /**
  111451. * The luminance threshold to find bright areas of the image to bloom.
  111452. */
  111453. threshold: number;
  111454. /**
  111455. * The strength of the bloom.
  111456. */
  111457. weight: number;
  111458. /**
  111459. * Specifies the size of the bloom blur kernel, relative to the final output size
  111460. */
  111461. kernel: number;
  111462. /**
  111463. * Creates a new instance of @see BloomEffect
  111464. * @param scene The scene the effect belongs to.
  111465. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111466. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111467. * @param bloomWeight The the strength of bloom.
  111468. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111469. * @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)
  111470. */
  111471. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111472. /**
  111473. * Disposes each of the internal effects for a given camera.
  111474. * @param camera The camera to dispose the effect on.
  111475. */
  111476. disposeEffects(camera: Camera): void;
  111477. /**
  111478. * @hidden Internal
  111479. */
  111480. _updateEffects(): void;
  111481. /**
  111482. * Internal
  111483. * @returns if all the contained post processes are ready.
  111484. * @hidden
  111485. */
  111486. _isReady(): boolean;
  111487. }
  111488. }
  111489. declare module BABYLON {
  111490. /** @hidden */
  111491. export var chromaticAberrationPixelShader: {
  111492. name: string;
  111493. shader: string;
  111494. };
  111495. }
  111496. declare module BABYLON {
  111497. /**
  111498. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111499. */
  111500. export class ChromaticAberrationPostProcess extends PostProcess {
  111501. /**
  111502. * The amount of seperation of rgb channels (default: 30)
  111503. */
  111504. aberrationAmount: number;
  111505. /**
  111506. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111507. */
  111508. radialIntensity: number;
  111509. /**
  111510. * 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))
  111511. */
  111512. direction: Vector2;
  111513. /**
  111514. * 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))
  111515. */
  111516. centerPosition: Vector2;
  111517. /**
  111518. * Creates a new instance ChromaticAberrationPostProcess
  111519. * @param name The name of the effect.
  111520. * @param screenWidth The width of the screen to apply the effect on.
  111521. * @param screenHeight The height of the screen to apply the effect on.
  111522. * @param options The required width/height ratio to downsize to before computing the render pass.
  111523. * @param camera The camera to apply the render pass to.
  111524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111525. * @param engine The engine which the post process will be applied. (default: current engine)
  111526. * @param reusable If the post process can be reused on the same frame. (default: false)
  111527. * @param textureType Type of textures used when performing the post process. (default: 0)
  111528. * @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)
  111529. */
  111530. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111531. }
  111532. }
  111533. declare module BABYLON {
  111534. /** @hidden */
  111535. export var circleOfConfusionPixelShader: {
  111536. name: string;
  111537. shader: string;
  111538. };
  111539. }
  111540. declare module BABYLON {
  111541. /**
  111542. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111543. */
  111544. export class CircleOfConfusionPostProcess extends PostProcess {
  111545. /**
  111546. * 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.
  111547. */
  111548. lensSize: number;
  111549. /**
  111550. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111551. */
  111552. fStop: number;
  111553. /**
  111554. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111555. */
  111556. focusDistance: number;
  111557. /**
  111558. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111559. */
  111560. focalLength: number;
  111561. private _depthTexture;
  111562. /**
  111563. * Creates a new instance CircleOfConfusionPostProcess
  111564. * @param name The name of the effect.
  111565. * @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.
  111566. * @param options The required width/height ratio to downsize to before computing the render pass.
  111567. * @param camera The camera to apply the render pass to.
  111568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111569. * @param engine The engine which the post process will be applied. (default: current engine)
  111570. * @param reusable If the post process can be reused on the same frame. (default: false)
  111571. * @param textureType Type of textures used when performing the post process. (default: 0)
  111572. * @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)
  111573. */
  111574. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111575. /**
  111576. * 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.
  111577. */
  111578. depthTexture: RenderTargetTexture;
  111579. }
  111580. }
  111581. declare module BABYLON {
  111582. /** @hidden */
  111583. export var colorCorrectionPixelShader: {
  111584. name: string;
  111585. shader: string;
  111586. };
  111587. }
  111588. declare module BABYLON {
  111589. /**
  111590. *
  111591. * This post-process allows the modification of rendered colors by using
  111592. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111593. *
  111594. * The object needs to be provided an url to a texture containing the color
  111595. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111596. * Use an image editing software to tweak the LUT to match your needs.
  111597. *
  111598. * For an example of a color LUT, see here:
  111599. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111600. * For explanations on color grading, see here:
  111601. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111602. *
  111603. */
  111604. export class ColorCorrectionPostProcess extends PostProcess {
  111605. private _colorTableTexture;
  111606. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111607. }
  111608. }
  111609. declare module BABYLON {
  111610. /** @hidden */
  111611. export var convolutionPixelShader: {
  111612. name: string;
  111613. shader: string;
  111614. };
  111615. }
  111616. declare module BABYLON {
  111617. /**
  111618. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111619. * input texture to perform effects such as edge detection or sharpening
  111620. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111621. */
  111622. export class ConvolutionPostProcess extends PostProcess {
  111623. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111624. kernel: number[];
  111625. /**
  111626. * Creates a new instance ConvolutionPostProcess
  111627. * @param name The name of the effect.
  111628. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111629. * @param options The required width/height ratio to downsize to before computing the render pass.
  111630. * @param camera The camera to apply the render pass to.
  111631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111632. * @param engine The engine which the post process will be applied. (default: current engine)
  111633. * @param reusable If the post process can be reused on the same frame. (default: false)
  111634. * @param textureType Type of textures used when performing the post process. (default: 0)
  111635. */
  111636. constructor(name: string,
  111637. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111638. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111639. /**
  111640. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111641. */
  111642. static EdgeDetect0Kernel: number[];
  111643. /**
  111644. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111645. */
  111646. static EdgeDetect1Kernel: number[];
  111647. /**
  111648. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111649. */
  111650. static EdgeDetect2Kernel: number[];
  111651. /**
  111652. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111653. */
  111654. static SharpenKernel: number[];
  111655. /**
  111656. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111657. */
  111658. static EmbossKernel: number[];
  111659. /**
  111660. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111661. */
  111662. static GaussianKernel: number[];
  111663. }
  111664. }
  111665. declare module BABYLON {
  111666. /**
  111667. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111668. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111669. * based on samples that have a large difference in distance than the center pixel.
  111670. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111671. */
  111672. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111673. direction: Vector2;
  111674. /**
  111675. * Creates a new instance CircleOfConfusionPostProcess
  111676. * @param name The name of the effect.
  111677. * @param scene The scene the effect belongs to.
  111678. * @param direction The direction the blur should be applied.
  111679. * @param kernel The size of the kernel used to blur.
  111680. * @param options The required width/height ratio to downsize to before computing the render pass.
  111681. * @param camera The camera to apply the render pass to.
  111682. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111683. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111685. * @param engine The engine which the post process will be applied. (default: current engine)
  111686. * @param reusable If the post process can be reused on the same frame. (default: false)
  111687. * @param textureType Type of textures used when performing the post process. (default: 0)
  111688. * @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)
  111689. */
  111690. 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);
  111691. }
  111692. }
  111693. declare module BABYLON {
  111694. /** @hidden */
  111695. export var depthOfFieldMergePixelShader: {
  111696. name: string;
  111697. shader: string;
  111698. };
  111699. }
  111700. declare module BABYLON {
  111701. /**
  111702. * Options to be set when merging outputs from the default pipeline.
  111703. */
  111704. export class DepthOfFieldMergePostProcessOptions {
  111705. /**
  111706. * The original image to merge on top of
  111707. */
  111708. originalFromInput: PostProcess;
  111709. /**
  111710. * Parameters to perform the merge of the depth of field effect
  111711. */
  111712. depthOfField?: {
  111713. circleOfConfusion: PostProcess;
  111714. blurSteps: Array<PostProcess>;
  111715. };
  111716. /**
  111717. * Parameters to perform the merge of bloom effect
  111718. */
  111719. bloom?: {
  111720. blurred: PostProcess;
  111721. weight: number;
  111722. };
  111723. }
  111724. /**
  111725. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111726. */
  111727. export class DepthOfFieldMergePostProcess extends PostProcess {
  111728. private blurSteps;
  111729. /**
  111730. * Creates a new instance of DepthOfFieldMergePostProcess
  111731. * @param name The name of the effect.
  111732. * @param originalFromInput Post process which's input will be used for the merge.
  111733. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111734. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111735. * @param options The required width/height ratio to downsize to before computing the render pass.
  111736. * @param camera The camera to apply the render pass to.
  111737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111738. * @param engine The engine which the post process will be applied. (default: current engine)
  111739. * @param reusable If the post process can be reused on the same frame. (default: false)
  111740. * @param textureType Type of textures used when performing the post process. (default: 0)
  111741. * @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)
  111742. */
  111743. 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);
  111744. /**
  111745. * Updates the effect with the current post process compile time values and recompiles the shader.
  111746. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  111747. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  111748. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  111749. * @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
  111750. * @param onCompiled Called when the shader has been compiled.
  111751. * @param onError Called if there is an error when compiling a shader.
  111752. */
  111753. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  111754. }
  111755. }
  111756. declare module BABYLON {
  111757. /**
  111758. * Specifies the level of max blur that should be applied when using the depth of field effect
  111759. */
  111760. export enum DepthOfFieldEffectBlurLevel {
  111761. /**
  111762. * Subtle blur
  111763. */
  111764. Low = 0,
  111765. /**
  111766. * Medium blur
  111767. */
  111768. Medium = 1,
  111769. /**
  111770. * Large blur
  111771. */
  111772. High = 2
  111773. }
  111774. /**
  111775. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  111776. */
  111777. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  111778. private _circleOfConfusion;
  111779. /**
  111780. * @hidden Internal, blurs from high to low
  111781. */
  111782. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  111783. private _depthOfFieldBlurY;
  111784. private _dofMerge;
  111785. /**
  111786. * @hidden Internal post processes in depth of field effect
  111787. */
  111788. _effects: Array<PostProcess>;
  111789. /**
  111790. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  111791. */
  111792. focalLength: number;
  111793. /**
  111794. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111795. */
  111796. fStop: number;
  111797. /**
  111798. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111799. */
  111800. focusDistance: number;
  111801. /**
  111802. * 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.
  111803. */
  111804. lensSize: number;
  111805. /**
  111806. * Creates a new instance DepthOfFieldEffect
  111807. * @param scene The scene the effect belongs to.
  111808. * @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.
  111809. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111810. * @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)
  111811. */
  111812. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  111813. /**
  111814. * 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.
  111815. */
  111816. depthTexture: RenderTargetTexture;
  111817. /**
  111818. * Disposes each of the internal effects for a given camera.
  111819. * @param camera The camera to dispose the effect on.
  111820. */
  111821. disposeEffects(camera: Camera): void;
  111822. /**
  111823. * @hidden Internal
  111824. */
  111825. _updateEffects(): void;
  111826. /**
  111827. * Internal
  111828. * @returns if all the contained post processes are ready.
  111829. * @hidden
  111830. */
  111831. _isReady(): boolean;
  111832. }
  111833. }
  111834. declare module BABYLON {
  111835. /** @hidden */
  111836. export var displayPassPixelShader: {
  111837. name: string;
  111838. shader: string;
  111839. };
  111840. }
  111841. declare module BABYLON {
  111842. /**
  111843. * DisplayPassPostProcess which produces an output the same as it's input
  111844. */
  111845. export class DisplayPassPostProcess extends PostProcess {
  111846. /**
  111847. * Creates the DisplayPassPostProcess
  111848. * @param name The name of the effect.
  111849. * @param options The required width/height ratio to downsize to before computing the render pass.
  111850. * @param camera The camera to apply the render pass to.
  111851. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111852. * @param engine The engine which the post process will be applied. (default: current engine)
  111853. * @param reusable If the post process can be reused on the same frame. (default: false)
  111854. */
  111855. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111856. }
  111857. }
  111858. declare module BABYLON {
  111859. /** @hidden */
  111860. export var filterPixelShader: {
  111861. name: string;
  111862. shader: string;
  111863. };
  111864. }
  111865. declare module BABYLON {
  111866. /**
  111867. * Applies a kernel filter to the image
  111868. */
  111869. export class FilterPostProcess extends PostProcess {
  111870. /** The matrix to be applied to the image */
  111871. kernelMatrix: Matrix;
  111872. /**
  111873. *
  111874. * @param name The name of the effect.
  111875. * @param kernelMatrix The matrix to be applied to the image
  111876. * @param options The required width/height ratio to downsize to before computing the render pass.
  111877. * @param camera The camera to apply the render pass to.
  111878. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111879. * @param engine The engine which the post process will be applied. (default: current engine)
  111880. * @param reusable If the post process can be reused on the same frame. (default: false)
  111881. */
  111882. constructor(name: string,
  111883. /** The matrix to be applied to the image */
  111884. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111885. }
  111886. }
  111887. declare module BABYLON {
  111888. /** @hidden */
  111889. export var fxaaPixelShader: {
  111890. name: string;
  111891. shader: string;
  111892. };
  111893. }
  111894. declare module BABYLON {
  111895. /** @hidden */
  111896. export var fxaaVertexShader: {
  111897. name: string;
  111898. shader: string;
  111899. };
  111900. }
  111901. declare module BABYLON {
  111902. /**
  111903. * Fxaa post process
  111904. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  111905. */
  111906. export class FxaaPostProcess extends PostProcess {
  111907. /** @hidden */
  111908. texelWidth: number;
  111909. /** @hidden */
  111910. texelHeight: number;
  111911. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111912. private _getDefines;
  111913. }
  111914. }
  111915. declare module BABYLON {
  111916. /** @hidden */
  111917. export var grainPixelShader: {
  111918. name: string;
  111919. shader: string;
  111920. };
  111921. }
  111922. declare module BABYLON {
  111923. /**
  111924. * The GrainPostProcess adds noise to the image at mid luminance levels
  111925. */
  111926. export class GrainPostProcess extends PostProcess {
  111927. /**
  111928. * The intensity of the grain added (default: 30)
  111929. */
  111930. intensity: number;
  111931. /**
  111932. * If the grain should be randomized on every frame
  111933. */
  111934. animated: boolean;
  111935. /**
  111936. * Creates a new instance of @see GrainPostProcess
  111937. * @param name The name of the effect.
  111938. * @param options The required width/height ratio to downsize to before computing the render pass.
  111939. * @param camera The camera to apply the render pass to.
  111940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111941. * @param engine The engine which the post process will be applied. (default: current engine)
  111942. * @param reusable If the post process can be reused on the same frame. (default: false)
  111943. * @param textureType Type of textures used when performing the post process. (default: 0)
  111944. * @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)
  111945. */
  111946. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111947. }
  111948. }
  111949. declare module BABYLON {
  111950. /** @hidden */
  111951. export var highlightsPixelShader: {
  111952. name: string;
  111953. shader: string;
  111954. };
  111955. }
  111956. declare module BABYLON {
  111957. /**
  111958. * Extracts highlights from the image
  111959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111960. */
  111961. export class HighlightsPostProcess extends PostProcess {
  111962. /**
  111963. * Extracts highlights from the image
  111964. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  111965. * @param name The name of the effect.
  111966. * @param options The required width/height ratio to downsize to before computing the render pass.
  111967. * @param camera The camera to apply the render pass to.
  111968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111969. * @param engine The engine which the post process will be applied. (default: current engine)
  111970. * @param reusable If the post process can be reused on the same frame. (default: false)
  111971. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  111972. */
  111973. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111974. }
  111975. }
  111976. declare module BABYLON {
  111977. /** @hidden */
  111978. export var mrtFragmentDeclaration: {
  111979. name: string;
  111980. shader: string;
  111981. };
  111982. }
  111983. declare module BABYLON {
  111984. /** @hidden */
  111985. export var geometryPixelShader: {
  111986. name: string;
  111987. shader: string;
  111988. };
  111989. }
  111990. declare module BABYLON {
  111991. /** @hidden */
  111992. export var geometryVertexShader: {
  111993. name: string;
  111994. shader: string;
  111995. };
  111996. }
  111997. declare module BABYLON {
  111998. /**
  111999. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112000. */
  112001. export class GeometryBufferRenderer {
  112002. /**
  112003. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112004. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112005. */
  112006. static readonly POSITION_TEXTURE_TYPE: number;
  112007. /**
  112008. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112009. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112010. */
  112011. static readonly VELOCITY_TEXTURE_TYPE: number;
  112012. /**
  112013. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112014. * in order to compute objects velocities when enableVelocity is set to "true"
  112015. * @hidden
  112016. */
  112017. _previousTransformationMatrices: {
  112018. [index: number]: Matrix;
  112019. };
  112020. private _scene;
  112021. private _multiRenderTarget;
  112022. private _ratio;
  112023. private _enablePosition;
  112024. private _enableVelocity;
  112025. private _positionIndex;
  112026. private _velocityIndex;
  112027. protected _effect: Effect;
  112028. protected _cachedDefines: string;
  112029. /**
  112030. * Set the render list (meshes to be rendered) used in the G buffer.
  112031. */
  112032. renderList: Mesh[];
  112033. /**
  112034. * Gets wether or not G buffer are supported by the running hardware.
  112035. * This requires draw buffer supports
  112036. */
  112037. readonly isSupported: boolean;
  112038. /**
  112039. * Returns the index of the given texture type in the G-Buffer textures array
  112040. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112041. * @returns the index of the given texture type in the G-Buffer textures array
  112042. */
  112043. getTextureIndex(textureType: number): number;
  112044. /**
  112045. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112046. */
  112047. /**
  112048. * Sets whether or not objects positions are enabled for the G buffer.
  112049. */
  112050. enablePosition: boolean;
  112051. /**
  112052. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112053. */
  112054. /**
  112055. * Sets wether or not objects velocities are enabled for the G buffer.
  112056. */
  112057. enableVelocity: boolean;
  112058. /**
  112059. * Gets the scene associated with the buffer.
  112060. */
  112061. readonly scene: Scene;
  112062. /**
  112063. * Gets the ratio used by the buffer during its creation.
  112064. * How big is the buffer related to the main canvas.
  112065. */
  112066. readonly ratio: number;
  112067. /** @hidden */
  112068. static _SceneComponentInitialization: (scene: Scene) => void;
  112069. /**
  112070. * Creates a new G Buffer for the scene
  112071. * @param scene The scene the buffer belongs to
  112072. * @param ratio How big is the buffer related to the main canvas.
  112073. */
  112074. constructor(scene: Scene, ratio?: number);
  112075. /**
  112076. * Checks wether everything is ready to render a submesh to the G buffer.
  112077. * @param subMesh the submesh to check readiness for
  112078. * @param useInstances is the mesh drawn using instance or not
  112079. * @returns true if ready otherwise false
  112080. */
  112081. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112082. /**
  112083. * Gets the current underlying G Buffer.
  112084. * @returns the buffer
  112085. */
  112086. getGBuffer(): MultiRenderTarget;
  112087. /**
  112088. * Gets the number of samples used to render the buffer (anti aliasing).
  112089. */
  112090. /**
  112091. * Sets the number of samples used to render the buffer (anti aliasing).
  112092. */
  112093. samples: number;
  112094. /**
  112095. * Disposes the renderer and frees up associated resources.
  112096. */
  112097. dispose(): void;
  112098. protected _createRenderTargets(): void;
  112099. }
  112100. }
  112101. declare module BABYLON {
  112102. interface Scene {
  112103. /** @hidden (Backing field) */
  112104. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112105. /**
  112106. * Gets or Sets the current geometry buffer associated to the scene.
  112107. */
  112108. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112109. /**
  112110. * Enables a GeometryBufferRender and associates it with the scene
  112111. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112112. * @returns the GeometryBufferRenderer
  112113. */
  112114. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112115. /**
  112116. * Disables the GeometryBufferRender associated with the scene
  112117. */
  112118. disableGeometryBufferRenderer(): void;
  112119. }
  112120. /**
  112121. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112122. * in several rendering techniques.
  112123. */
  112124. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112125. /**
  112126. * The component name helpful to identify the component in the list of scene components.
  112127. */
  112128. readonly name: string;
  112129. /**
  112130. * The scene the component belongs to.
  112131. */
  112132. scene: Scene;
  112133. /**
  112134. * Creates a new instance of the component for the given scene
  112135. * @param scene Defines the scene to register the component in
  112136. */
  112137. constructor(scene: Scene);
  112138. /**
  112139. * Registers the component in a given scene
  112140. */
  112141. register(): void;
  112142. /**
  112143. * Rebuilds the elements related to this component in case of
  112144. * context lost for instance.
  112145. */
  112146. rebuild(): void;
  112147. /**
  112148. * Disposes the component and the associated ressources
  112149. */
  112150. dispose(): void;
  112151. private _gatherRenderTargets;
  112152. }
  112153. }
  112154. declare module BABYLON {
  112155. /** @hidden */
  112156. export var motionBlurPixelShader: {
  112157. name: string;
  112158. shader: string;
  112159. };
  112160. }
  112161. declare module BABYLON {
  112162. /**
  112163. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112164. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112165. * As an example, all you have to do is to create the post-process:
  112166. * var mb = new BABYLON.MotionBlurPostProcess(
  112167. * 'mb', // The name of the effect.
  112168. * scene, // The scene containing the objects to blur according to their velocity.
  112169. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112170. * camera // The camera to apply the render pass to.
  112171. * );
  112172. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112173. */
  112174. export class MotionBlurPostProcess extends PostProcess {
  112175. /**
  112176. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112177. */
  112178. motionStrength: number;
  112179. /**
  112180. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112181. */
  112182. /**
  112183. * Sets the number of iterations to be used for motion blur quality
  112184. */
  112185. motionBlurSamples: number;
  112186. private _motionBlurSamples;
  112187. private _geometryBufferRenderer;
  112188. /**
  112189. * Creates a new instance MotionBlurPostProcess
  112190. * @param name The name of the effect.
  112191. * @param scene The scene containing the objects to blur according to their velocity.
  112192. * @param options The required width/height ratio to downsize to before computing the render pass.
  112193. * @param camera The camera to apply the render pass to.
  112194. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112195. * @param engine The engine which the post process will be applied. (default: current engine)
  112196. * @param reusable If the post process can be reused on the same frame. (default: false)
  112197. * @param textureType Type of textures used when performing the post process. (default: 0)
  112198. * @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)
  112199. */
  112200. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112201. /**
  112202. * Disposes the post process.
  112203. * @param camera The camera to dispose the post process on.
  112204. */
  112205. dispose(camera?: Camera): void;
  112206. }
  112207. }
  112208. declare module BABYLON {
  112209. /** @hidden */
  112210. export var refractionPixelShader: {
  112211. name: string;
  112212. shader: string;
  112213. };
  112214. }
  112215. declare module BABYLON {
  112216. /**
  112217. * Post process which applies a refractin texture
  112218. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112219. */
  112220. export class RefractionPostProcess extends PostProcess {
  112221. /** the base color of the refraction (used to taint the rendering) */
  112222. color: Color3;
  112223. /** simulated refraction depth */
  112224. depth: number;
  112225. /** the coefficient of the base color (0 to remove base color tainting) */
  112226. colorLevel: number;
  112227. private _refTexture;
  112228. private _ownRefractionTexture;
  112229. /**
  112230. * Gets or sets the refraction texture
  112231. * Please note that you are responsible for disposing the texture if you set it manually
  112232. */
  112233. refractionTexture: Texture;
  112234. /**
  112235. * Initializes the RefractionPostProcess
  112236. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112237. * @param name The name of the effect.
  112238. * @param refractionTextureUrl Url of the refraction texture to use
  112239. * @param color the base color of the refraction (used to taint the rendering)
  112240. * @param depth simulated refraction depth
  112241. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112242. * @param camera The camera to apply the render pass to.
  112243. * @param options The required width/height ratio to downsize to before computing the render pass.
  112244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112245. * @param engine The engine which the post process will be applied. (default: current engine)
  112246. * @param reusable If the post process can be reused on the same frame. (default: false)
  112247. */
  112248. constructor(name: string, refractionTextureUrl: string,
  112249. /** the base color of the refraction (used to taint the rendering) */
  112250. color: Color3,
  112251. /** simulated refraction depth */
  112252. depth: number,
  112253. /** the coefficient of the base color (0 to remove base color tainting) */
  112254. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112255. /**
  112256. * Disposes of the post process
  112257. * @param camera Camera to dispose post process on
  112258. */
  112259. dispose(camera: Camera): void;
  112260. }
  112261. }
  112262. declare module BABYLON {
  112263. /** @hidden */
  112264. export var sharpenPixelShader: {
  112265. name: string;
  112266. shader: string;
  112267. };
  112268. }
  112269. declare module BABYLON {
  112270. /**
  112271. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112272. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112273. */
  112274. export class SharpenPostProcess extends PostProcess {
  112275. /**
  112276. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112277. */
  112278. colorAmount: number;
  112279. /**
  112280. * How much sharpness should be applied (default: 0.3)
  112281. */
  112282. edgeAmount: number;
  112283. /**
  112284. * Creates a new instance ConvolutionPostProcess
  112285. * @param name The name of the effect.
  112286. * @param options The required width/height ratio to downsize to before computing the render pass.
  112287. * @param camera The camera to apply the render pass to.
  112288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112289. * @param engine The engine which the post process will be applied. (default: current engine)
  112290. * @param reusable If the post process can be reused on the same frame. (default: false)
  112291. * @param textureType Type of textures used when performing the post process. (default: 0)
  112292. * @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)
  112293. */
  112294. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112295. }
  112296. }
  112297. declare module BABYLON {
  112298. /**
  112299. * PostProcessRenderPipeline
  112300. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112301. */
  112302. export class PostProcessRenderPipeline {
  112303. private engine;
  112304. private _renderEffects;
  112305. private _renderEffectsForIsolatedPass;
  112306. /**
  112307. * List of inspectable custom properties (used by the Inspector)
  112308. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112309. */
  112310. inspectableCustomProperties: IInspectable[];
  112311. /**
  112312. * @hidden
  112313. */
  112314. protected _cameras: Camera[];
  112315. /** @hidden */
  112316. _name: string;
  112317. /**
  112318. * Gets pipeline name
  112319. */
  112320. readonly name: string;
  112321. /**
  112322. * Initializes a PostProcessRenderPipeline
  112323. * @param engine engine to add the pipeline to
  112324. * @param name name of the pipeline
  112325. */
  112326. constructor(engine: Engine, name: string);
  112327. /**
  112328. * Gets the class name
  112329. * @returns "PostProcessRenderPipeline"
  112330. */
  112331. getClassName(): string;
  112332. /**
  112333. * If all the render effects in the pipeline are supported
  112334. */
  112335. readonly isSupported: boolean;
  112336. /**
  112337. * Adds an effect to the pipeline
  112338. * @param renderEffect the effect to add
  112339. */
  112340. addEffect(renderEffect: PostProcessRenderEffect): void;
  112341. /** @hidden */
  112342. _rebuild(): void;
  112343. /** @hidden */
  112344. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112345. /** @hidden */
  112346. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112347. /** @hidden */
  112348. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112349. /** @hidden */
  112350. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112351. /** @hidden */
  112352. _attachCameras(cameras: Camera, unique: boolean): void;
  112353. /** @hidden */
  112354. _attachCameras(cameras: Camera[], unique: boolean): void;
  112355. /** @hidden */
  112356. _detachCameras(cameras: Camera): void;
  112357. /** @hidden */
  112358. _detachCameras(cameras: Nullable<Camera[]>): void;
  112359. /** @hidden */
  112360. _update(): void;
  112361. /** @hidden */
  112362. _reset(): void;
  112363. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112364. /**
  112365. * Disposes of the pipeline
  112366. */
  112367. dispose(): void;
  112368. }
  112369. }
  112370. declare module BABYLON {
  112371. /**
  112372. * PostProcessRenderPipelineManager class
  112373. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112374. */
  112375. export class PostProcessRenderPipelineManager {
  112376. private _renderPipelines;
  112377. /**
  112378. * Initializes a PostProcessRenderPipelineManager
  112379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112380. */
  112381. constructor();
  112382. /**
  112383. * Gets the list of supported render pipelines
  112384. */
  112385. readonly supportedPipelines: PostProcessRenderPipeline[];
  112386. /**
  112387. * Adds a pipeline to the manager
  112388. * @param renderPipeline The pipeline to add
  112389. */
  112390. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112391. /**
  112392. * Attaches a camera to the pipeline
  112393. * @param renderPipelineName The name of the pipeline to attach to
  112394. * @param cameras the camera to attach
  112395. * @param unique if the camera can be attached multiple times to the pipeline
  112396. */
  112397. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112398. /**
  112399. * Detaches a camera from the pipeline
  112400. * @param renderPipelineName The name of the pipeline to detach from
  112401. * @param cameras the camera to detach
  112402. */
  112403. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112404. /**
  112405. * Enables an effect by name on a pipeline
  112406. * @param renderPipelineName the name of the pipeline to enable the effect in
  112407. * @param renderEffectName the name of the effect to enable
  112408. * @param cameras the cameras that the effect should be enabled on
  112409. */
  112410. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112411. /**
  112412. * Disables an effect by name on a pipeline
  112413. * @param renderPipelineName the name of the pipeline to disable the effect in
  112414. * @param renderEffectName the name of the effect to disable
  112415. * @param cameras the cameras that the effect should be disabled on
  112416. */
  112417. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112418. /**
  112419. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112420. */
  112421. update(): void;
  112422. /** @hidden */
  112423. _rebuild(): void;
  112424. /**
  112425. * Disposes of the manager and pipelines
  112426. */
  112427. dispose(): void;
  112428. }
  112429. }
  112430. declare module BABYLON {
  112431. interface Scene {
  112432. /** @hidden (Backing field) */
  112433. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112434. /**
  112435. * Gets the postprocess render pipeline manager
  112436. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112437. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112438. */
  112439. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112440. }
  112441. /**
  112442. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112443. */
  112444. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112445. /**
  112446. * The component name helpfull to identify the component in the list of scene components.
  112447. */
  112448. readonly name: string;
  112449. /**
  112450. * The scene the component belongs to.
  112451. */
  112452. scene: Scene;
  112453. /**
  112454. * Creates a new instance of the component for the given scene
  112455. * @param scene Defines the scene to register the component in
  112456. */
  112457. constructor(scene: Scene);
  112458. /**
  112459. * Registers the component in a given scene
  112460. */
  112461. register(): void;
  112462. /**
  112463. * Rebuilds the elements related to this component in case of
  112464. * context lost for instance.
  112465. */
  112466. rebuild(): void;
  112467. /**
  112468. * Disposes the component and the associated ressources
  112469. */
  112470. dispose(): void;
  112471. private _gatherRenderTargets;
  112472. }
  112473. }
  112474. declare module BABYLON {
  112475. /**
  112476. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112477. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112478. */
  112479. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112480. private _scene;
  112481. private _camerasToBeAttached;
  112482. /**
  112483. * ID of the sharpen post process,
  112484. */
  112485. private readonly SharpenPostProcessId;
  112486. /**
  112487. * @ignore
  112488. * ID of the image processing post process;
  112489. */
  112490. readonly ImageProcessingPostProcessId: string;
  112491. /**
  112492. * @ignore
  112493. * ID of the Fast Approximate Anti-Aliasing post process;
  112494. */
  112495. readonly FxaaPostProcessId: string;
  112496. /**
  112497. * ID of the chromatic aberration post process,
  112498. */
  112499. private readonly ChromaticAberrationPostProcessId;
  112500. /**
  112501. * ID of the grain post process
  112502. */
  112503. private readonly GrainPostProcessId;
  112504. /**
  112505. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112506. */
  112507. sharpen: SharpenPostProcess;
  112508. private _sharpenEffect;
  112509. private bloom;
  112510. /**
  112511. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112512. */
  112513. depthOfField: DepthOfFieldEffect;
  112514. /**
  112515. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112516. */
  112517. fxaa: FxaaPostProcess;
  112518. /**
  112519. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112520. */
  112521. imageProcessing: ImageProcessingPostProcess;
  112522. /**
  112523. * Chromatic aberration post process which will shift rgb colors in the image
  112524. */
  112525. chromaticAberration: ChromaticAberrationPostProcess;
  112526. private _chromaticAberrationEffect;
  112527. /**
  112528. * Grain post process which add noise to the image
  112529. */
  112530. grain: GrainPostProcess;
  112531. private _grainEffect;
  112532. /**
  112533. * Glow post process which adds a glow to emissive areas of the image
  112534. */
  112535. private _glowLayer;
  112536. /**
  112537. * Animations which can be used to tweak settings over a period of time
  112538. */
  112539. animations: Animation[];
  112540. private _imageProcessingConfigurationObserver;
  112541. private _sharpenEnabled;
  112542. private _bloomEnabled;
  112543. private _depthOfFieldEnabled;
  112544. private _depthOfFieldBlurLevel;
  112545. private _fxaaEnabled;
  112546. private _imageProcessingEnabled;
  112547. private _defaultPipelineTextureType;
  112548. private _bloomScale;
  112549. private _chromaticAberrationEnabled;
  112550. private _grainEnabled;
  112551. private _buildAllowed;
  112552. /**
  112553. * Gets active scene
  112554. */
  112555. readonly scene: Scene;
  112556. /**
  112557. * Enable or disable the sharpen process from the pipeline
  112558. */
  112559. sharpenEnabled: boolean;
  112560. private _resizeObserver;
  112561. private _hardwareScaleLevel;
  112562. private _bloomKernel;
  112563. /**
  112564. * Specifies the size of the bloom blur kernel, relative to the final output size
  112565. */
  112566. bloomKernel: number;
  112567. /**
  112568. * Specifies the weight of the bloom in the final rendering
  112569. */
  112570. private _bloomWeight;
  112571. /**
  112572. * Specifies the luma threshold for the area that will be blurred by the bloom
  112573. */
  112574. private _bloomThreshold;
  112575. private _hdr;
  112576. /**
  112577. * The strength of the bloom.
  112578. */
  112579. bloomWeight: number;
  112580. /**
  112581. * The strength of the bloom.
  112582. */
  112583. bloomThreshold: number;
  112584. /**
  112585. * The scale of the bloom, lower value will provide better performance.
  112586. */
  112587. bloomScale: number;
  112588. /**
  112589. * Enable or disable the bloom from the pipeline
  112590. */
  112591. bloomEnabled: boolean;
  112592. private _rebuildBloom;
  112593. /**
  112594. * If the depth of field is enabled.
  112595. */
  112596. depthOfFieldEnabled: boolean;
  112597. /**
  112598. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112599. */
  112600. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112601. /**
  112602. * If the anti aliasing is enabled.
  112603. */
  112604. fxaaEnabled: boolean;
  112605. private _samples;
  112606. /**
  112607. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112608. */
  112609. samples: number;
  112610. /**
  112611. * If image processing is enabled.
  112612. */
  112613. imageProcessingEnabled: boolean;
  112614. /**
  112615. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112616. */
  112617. glowLayerEnabled: boolean;
  112618. /**
  112619. * Enable or disable the chromaticAberration process from the pipeline
  112620. */
  112621. chromaticAberrationEnabled: boolean;
  112622. /**
  112623. * Enable or disable the grain process from the pipeline
  112624. */
  112625. grainEnabled: boolean;
  112626. /**
  112627. * @constructor
  112628. * @param name - The rendering pipeline name (default: "")
  112629. * @param hdr - If high dynamic range textures should be used (default: true)
  112630. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112631. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112632. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112633. */
  112634. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112635. /**
  112636. * Get the class name
  112637. * @returns "DefaultRenderingPipeline"
  112638. */
  112639. getClassName(): string;
  112640. /**
  112641. * Force the compilation of the entire pipeline.
  112642. */
  112643. prepare(): void;
  112644. private _hasCleared;
  112645. private _prevPostProcess;
  112646. private _prevPrevPostProcess;
  112647. private _setAutoClearAndTextureSharing;
  112648. private _depthOfFieldSceneObserver;
  112649. private _buildPipeline;
  112650. private _disposePostProcesses;
  112651. /**
  112652. * Adds a camera to the pipeline
  112653. * @param camera the camera to be added
  112654. */
  112655. addCamera(camera: Camera): void;
  112656. /**
  112657. * Removes a camera from the pipeline
  112658. * @param camera the camera to remove
  112659. */
  112660. removeCamera(camera: Camera): void;
  112661. /**
  112662. * Dispose of the pipeline and stop all post processes
  112663. */
  112664. dispose(): void;
  112665. /**
  112666. * Serialize the rendering pipeline (Used when exporting)
  112667. * @returns the serialized object
  112668. */
  112669. serialize(): any;
  112670. /**
  112671. * Parse the serialized pipeline
  112672. * @param source Source pipeline.
  112673. * @param scene The scene to load the pipeline to.
  112674. * @param rootUrl The URL of the serialized pipeline.
  112675. * @returns An instantiated pipeline from the serialized object.
  112676. */
  112677. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112678. }
  112679. }
  112680. declare module BABYLON {
  112681. /** @hidden */
  112682. export var lensHighlightsPixelShader: {
  112683. name: string;
  112684. shader: string;
  112685. };
  112686. }
  112687. declare module BABYLON {
  112688. /** @hidden */
  112689. export var depthOfFieldPixelShader: {
  112690. name: string;
  112691. shader: string;
  112692. };
  112693. }
  112694. declare module BABYLON {
  112695. /**
  112696. * BABYLON.JS Chromatic Aberration GLSL Shader
  112697. * Author: Olivier Guyot
  112698. * Separates very slightly R, G and B colors on the edges of the screen
  112699. * Inspired by Francois Tarlier & Martins Upitis
  112700. */
  112701. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112702. /**
  112703. * @ignore
  112704. * The chromatic aberration PostProcess id in the pipeline
  112705. */
  112706. LensChromaticAberrationEffect: string;
  112707. /**
  112708. * @ignore
  112709. * The highlights enhancing PostProcess id in the pipeline
  112710. */
  112711. HighlightsEnhancingEffect: string;
  112712. /**
  112713. * @ignore
  112714. * The depth-of-field PostProcess id in the pipeline
  112715. */
  112716. LensDepthOfFieldEffect: string;
  112717. private _scene;
  112718. private _depthTexture;
  112719. private _grainTexture;
  112720. private _chromaticAberrationPostProcess;
  112721. private _highlightsPostProcess;
  112722. private _depthOfFieldPostProcess;
  112723. private _edgeBlur;
  112724. private _grainAmount;
  112725. private _chromaticAberration;
  112726. private _distortion;
  112727. private _highlightsGain;
  112728. private _highlightsThreshold;
  112729. private _dofDistance;
  112730. private _dofAperture;
  112731. private _dofDarken;
  112732. private _dofPentagon;
  112733. private _blurNoise;
  112734. /**
  112735. * @constructor
  112736. *
  112737. * Effect parameters are as follow:
  112738. * {
  112739. * chromatic_aberration: number; // from 0 to x (1 for realism)
  112740. * edge_blur: number; // from 0 to x (1 for realism)
  112741. * distortion: number; // from 0 to x (1 for realism)
  112742. * grain_amount: number; // from 0 to 1
  112743. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  112744. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  112745. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  112746. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  112747. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  112748. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  112749. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  112750. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  112751. * }
  112752. * Note: if an effect parameter is unset, effect is disabled
  112753. *
  112754. * @param name The rendering pipeline name
  112755. * @param parameters - An object containing all parameters (see above)
  112756. * @param scene The scene linked to this pipeline
  112757. * @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)
  112758. * @param cameras The array of cameras that the rendering pipeline will be attached to
  112759. */
  112760. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  112761. /**
  112762. * Get the class name
  112763. * @returns "LensRenderingPipeline"
  112764. */
  112765. getClassName(): string;
  112766. /**
  112767. * Gets associated scene
  112768. */
  112769. readonly scene: Scene;
  112770. /**
  112771. * Gets or sets the edge blur
  112772. */
  112773. edgeBlur: number;
  112774. /**
  112775. * Gets or sets the grain amount
  112776. */
  112777. grainAmount: number;
  112778. /**
  112779. * Gets or sets the chromatic aberration amount
  112780. */
  112781. chromaticAberration: number;
  112782. /**
  112783. * Gets or sets the depth of field aperture
  112784. */
  112785. dofAperture: number;
  112786. /**
  112787. * Gets or sets the edge distortion
  112788. */
  112789. edgeDistortion: number;
  112790. /**
  112791. * Gets or sets the depth of field distortion
  112792. */
  112793. dofDistortion: number;
  112794. /**
  112795. * Gets or sets the darken out of focus amount
  112796. */
  112797. darkenOutOfFocus: number;
  112798. /**
  112799. * Gets or sets a boolean indicating if blur noise is enabled
  112800. */
  112801. blurNoise: boolean;
  112802. /**
  112803. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  112804. */
  112805. pentagonBokeh: boolean;
  112806. /**
  112807. * Gets or sets the highlight grain amount
  112808. */
  112809. highlightsGain: number;
  112810. /**
  112811. * Gets or sets the highlight threshold
  112812. */
  112813. highlightsThreshold: number;
  112814. /**
  112815. * Sets the amount of blur at the edges
  112816. * @param amount blur amount
  112817. */
  112818. setEdgeBlur(amount: number): void;
  112819. /**
  112820. * Sets edge blur to 0
  112821. */
  112822. disableEdgeBlur(): void;
  112823. /**
  112824. * Sets the amout of grain
  112825. * @param amount Amount of grain
  112826. */
  112827. setGrainAmount(amount: number): void;
  112828. /**
  112829. * Set grain amount to 0
  112830. */
  112831. disableGrain(): void;
  112832. /**
  112833. * Sets the chromatic aberration amount
  112834. * @param amount amount of chromatic aberration
  112835. */
  112836. setChromaticAberration(amount: number): void;
  112837. /**
  112838. * Sets chromatic aberration amount to 0
  112839. */
  112840. disableChromaticAberration(): void;
  112841. /**
  112842. * Sets the EdgeDistortion amount
  112843. * @param amount amount of EdgeDistortion
  112844. */
  112845. setEdgeDistortion(amount: number): void;
  112846. /**
  112847. * Sets edge distortion to 0
  112848. */
  112849. disableEdgeDistortion(): void;
  112850. /**
  112851. * Sets the FocusDistance amount
  112852. * @param amount amount of FocusDistance
  112853. */
  112854. setFocusDistance(amount: number): void;
  112855. /**
  112856. * Disables depth of field
  112857. */
  112858. disableDepthOfField(): void;
  112859. /**
  112860. * Sets the Aperture amount
  112861. * @param amount amount of Aperture
  112862. */
  112863. setAperture(amount: number): void;
  112864. /**
  112865. * Sets the DarkenOutOfFocus amount
  112866. * @param amount amount of DarkenOutOfFocus
  112867. */
  112868. setDarkenOutOfFocus(amount: number): void;
  112869. private _pentagonBokehIsEnabled;
  112870. /**
  112871. * Creates a pentagon bokeh effect
  112872. */
  112873. enablePentagonBokeh(): void;
  112874. /**
  112875. * Disables the pentagon bokeh effect
  112876. */
  112877. disablePentagonBokeh(): void;
  112878. /**
  112879. * Enables noise blur
  112880. */
  112881. enableNoiseBlur(): void;
  112882. /**
  112883. * Disables noise blur
  112884. */
  112885. disableNoiseBlur(): void;
  112886. /**
  112887. * Sets the HighlightsGain amount
  112888. * @param amount amount of HighlightsGain
  112889. */
  112890. setHighlightsGain(amount: number): void;
  112891. /**
  112892. * Sets the HighlightsThreshold amount
  112893. * @param amount amount of HighlightsThreshold
  112894. */
  112895. setHighlightsThreshold(amount: number): void;
  112896. /**
  112897. * Disables highlights
  112898. */
  112899. disableHighlights(): void;
  112900. /**
  112901. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  112902. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  112903. */
  112904. dispose(disableDepthRender?: boolean): void;
  112905. private _createChromaticAberrationPostProcess;
  112906. private _createHighlightsPostProcess;
  112907. private _createDepthOfFieldPostProcess;
  112908. private _createGrainTexture;
  112909. }
  112910. }
  112911. declare module BABYLON {
  112912. /** @hidden */
  112913. export var ssao2PixelShader: {
  112914. name: string;
  112915. shader: string;
  112916. };
  112917. }
  112918. declare module BABYLON {
  112919. /** @hidden */
  112920. export var ssaoCombinePixelShader: {
  112921. name: string;
  112922. shader: string;
  112923. };
  112924. }
  112925. declare module BABYLON {
  112926. /**
  112927. * Render pipeline to produce ssao effect
  112928. */
  112929. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  112930. /**
  112931. * @ignore
  112932. * The PassPostProcess id in the pipeline that contains the original scene color
  112933. */
  112934. SSAOOriginalSceneColorEffect: string;
  112935. /**
  112936. * @ignore
  112937. * The SSAO PostProcess id in the pipeline
  112938. */
  112939. SSAORenderEffect: string;
  112940. /**
  112941. * @ignore
  112942. * The horizontal blur PostProcess id in the pipeline
  112943. */
  112944. SSAOBlurHRenderEffect: string;
  112945. /**
  112946. * @ignore
  112947. * The vertical blur PostProcess id in the pipeline
  112948. */
  112949. SSAOBlurVRenderEffect: string;
  112950. /**
  112951. * @ignore
  112952. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  112953. */
  112954. SSAOCombineRenderEffect: string;
  112955. /**
  112956. * The output strength of the SSAO post-process. Default value is 1.0.
  112957. */
  112958. totalStrength: number;
  112959. /**
  112960. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  112961. */
  112962. maxZ: number;
  112963. /**
  112964. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  112965. */
  112966. minZAspect: number;
  112967. private _samples;
  112968. /**
  112969. * Number of samples used for the SSAO calculations. Default value is 8
  112970. */
  112971. samples: number;
  112972. private _textureSamples;
  112973. /**
  112974. * Number of samples to use for antialiasing
  112975. */
  112976. textureSamples: number;
  112977. /**
  112978. * Ratio object used for SSAO ratio and blur ratio
  112979. */
  112980. private _ratio;
  112981. /**
  112982. * Dynamically generated sphere sampler.
  112983. */
  112984. private _sampleSphere;
  112985. /**
  112986. * Blur filter offsets
  112987. */
  112988. private _samplerOffsets;
  112989. private _expensiveBlur;
  112990. /**
  112991. * If bilateral blur should be used
  112992. */
  112993. expensiveBlur: boolean;
  112994. /**
  112995. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  112996. */
  112997. radius: number;
  112998. /**
  112999. * The base color of the SSAO post-process
  113000. * The final result is "base + ssao" between [0, 1]
  113001. */
  113002. base: number;
  113003. /**
  113004. * Support test.
  113005. */
  113006. static readonly IsSupported: boolean;
  113007. private _scene;
  113008. private _depthTexture;
  113009. private _normalTexture;
  113010. private _randomTexture;
  113011. private _originalColorPostProcess;
  113012. private _ssaoPostProcess;
  113013. private _blurHPostProcess;
  113014. private _blurVPostProcess;
  113015. private _ssaoCombinePostProcess;
  113016. private _firstUpdate;
  113017. /**
  113018. * Gets active scene
  113019. */
  113020. readonly scene: Scene;
  113021. /**
  113022. * @constructor
  113023. * @param name The rendering pipeline name
  113024. * @param scene The scene linked to this pipeline
  113025. * @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 }
  113026. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113027. */
  113028. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113029. /**
  113030. * Get the class name
  113031. * @returns "SSAO2RenderingPipeline"
  113032. */
  113033. getClassName(): string;
  113034. /**
  113035. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113036. */
  113037. dispose(disableGeometryBufferRenderer?: boolean): void;
  113038. private _createBlurPostProcess;
  113039. /** @hidden */
  113040. _rebuild(): void;
  113041. private _bits;
  113042. private _radicalInverse_VdC;
  113043. private _hammersley;
  113044. private _hemisphereSample_uniform;
  113045. private _generateHemisphere;
  113046. private _createSSAOPostProcess;
  113047. private _createSSAOCombinePostProcess;
  113048. private _createRandomTexture;
  113049. /**
  113050. * Serialize the rendering pipeline (Used when exporting)
  113051. * @returns the serialized object
  113052. */
  113053. serialize(): any;
  113054. /**
  113055. * Parse the serialized pipeline
  113056. * @param source Source pipeline.
  113057. * @param scene The scene to load the pipeline to.
  113058. * @param rootUrl The URL of the serialized pipeline.
  113059. * @returns An instantiated pipeline from the serialized object.
  113060. */
  113061. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113062. }
  113063. }
  113064. declare module BABYLON {
  113065. /** @hidden */
  113066. export var ssaoPixelShader: {
  113067. name: string;
  113068. shader: string;
  113069. };
  113070. }
  113071. declare module BABYLON {
  113072. /**
  113073. * Render pipeline to produce ssao effect
  113074. */
  113075. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113076. /**
  113077. * @ignore
  113078. * The PassPostProcess id in the pipeline that contains the original scene color
  113079. */
  113080. SSAOOriginalSceneColorEffect: string;
  113081. /**
  113082. * @ignore
  113083. * The SSAO PostProcess id in the pipeline
  113084. */
  113085. SSAORenderEffect: string;
  113086. /**
  113087. * @ignore
  113088. * The horizontal blur PostProcess id in the pipeline
  113089. */
  113090. SSAOBlurHRenderEffect: string;
  113091. /**
  113092. * @ignore
  113093. * The vertical blur PostProcess id in the pipeline
  113094. */
  113095. SSAOBlurVRenderEffect: string;
  113096. /**
  113097. * @ignore
  113098. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113099. */
  113100. SSAOCombineRenderEffect: string;
  113101. /**
  113102. * The output strength of the SSAO post-process. Default value is 1.0.
  113103. */
  113104. totalStrength: number;
  113105. /**
  113106. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113107. */
  113108. radius: number;
  113109. /**
  113110. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113111. * Must not be equal to fallOff and superior to fallOff.
  113112. * Default value is 0.0075
  113113. */
  113114. area: number;
  113115. /**
  113116. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113117. * Must not be equal to area and inferior to area.
  113118. * Default value is 0.000001
  113119. */
  113120. fallOff: number;
  113121. /**
  113122. * The base color of the SSAO post-process
  113123. * The final result is "base + ssao" between [0, 1]
  113124. */
  113125. base: number;
  113126. private _scene;
  113127. private _depthTexture;
  113128. private _randomTexture;
  113129. private _originalColorPostProcess;
  113130. private _ssaoPostProcess;
  113131. private _blurHPostProcess;
  113132. private _blurVPostProcess;
  113133. private _ssaoCombinePostProcess;
  113134. private _firstUpdate;
  113135. /**
  113136. * Gets active scene
  113137. */
  113138. readonly scene: Scene;
  113139. /**
  113140. * @constructor
  113141. * @param name - The rendering pipeline name
  113142. * @param scene - The scene linked to this pipeline
  113143. * @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 }
  113144. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113145. */
  113146. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113147. /**
  113148. * Get the class name
  113149. * @returns "SSAORenderingPipeline"
  113150. */
  113151. getClassName(): string;
  113152. /**
  113153. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113154. */
  113155. dispose(disableDepthRender?: boolean): void;
  113156. private _createBlurPostProcess;
  113157. /** @hidden */
  113158. _rebuild(): void;
  113159. private _createSSAOPostProcess;
  113160. private _createSSAOCombinePostProcess;
  113161. private _createRandomTexture;
  113162. }
  113163. }
  113164. declare module BABYLON {
  113165. /** @hidden */
  113166. export var standardPixelShader: {
  113167. name: string;
  113168. shader: string;
  113169. };
  113170. }
  113171. declare module BABYLON {
  113172. /**
  113173. * Standard rendering pipeline
  113174. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113175. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113176. */
  113177. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113178. /**
  113179. * Public members
  113180. */
  113181. /**
  113182. * Post-process which contains the original scene color before the pipeline applies all the effects
  113183. */
  113184. originalPostProcess: Nullable<PostProcess>;
  113185. /**
  113186. * Post-process used to down scale an image x4
  113187. */
  113188. downSampleX4PostProcess: Nullable<PostProcess>;
  113189. /**
  113190. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113191. */
  113192. brightPassPostProcess: Nullable<PostProcess>;
  113193. /**
  113194. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113195. */
  113196. blurHPostProcesses: PostProcess[];
  113197. /**
  113198. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113199. */
  113200. blurVPostProcesses: PostProcess[];
  113201. /**
  113202. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113203. */
  113204. textureAdderPostProcess: Nullable<PostProcess>;
  113205. /**
  113206. * Post-process used to create volumetric lighting effect
  113207. */
  113208. volumetricLightPostProcess: Nullable<PostProcess>;
  113209. /**
  113210. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113211. */
  113212. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113213. /**
  113214. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113215. */
  113216. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113217. /**
  113218. * Post-process used to merge the volumetric light effect and the real scene color
  113219. */
  113220. volumetricLightMergePostProces: Nullable<PostProcess>;
  113221. /**
  113222. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113223. */
  113224. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113225. /**
  113226. * Base post-process used to calculate the average luminance of the final image for HDR
  113227. */
  113228. luminancePostProcess: Nullable<PostProcess>;
  113229. /**
  113230. * Post-processes used to create down sample post-processes in order to get
  113231. * the average luminance of the final image for HDR
  113232. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113233. */
  113234. luminanceDownSamplePostProcesses: PostProcess[];
  113235. /**
  113236. * Post-process used to create a HDR effect (light adaptation)
  113237. */
  113238. hdrPostProcess: Nullable<PostProcess>;
  113239. /**
  113240. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113241. */
  113242. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113243. /**
  113244. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113245. */
  113246. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113247. /**
  113248. * Post-process used to merge the final HDR post-process and the real scene color
  113249. */
  113250. hdrFinalPostProcess: Nullable<PostProcess>;
  113251. /**
  113252. * Post-process used to create a lens flare effect
  113253. */
  113254. lensFlarePostProcess: Nullable<PostProcess>;
  113255. /**
  113256. * Post-process that merges the result of the lens flare post-process and the real scene color
  113257. */
  113258. lensFlareComposePostProcess: Nullable<PostProcess>;
  113259. /**
  113260. * Post-process used to create a motion blur effect
  113261. */
  113262. motionBlurPostProcess: Nullable<PostProcess>;
  113263. /**
  113264. * Post-process used to create a depth of field effect
  113265. */
  113266. depthOfFieldPostProcess: Nullable<PostProcess>;
  113267. /**
  113268. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113269. */
  113270. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113271. /**
  113272. * Represents the brightness threshold in order to configure the illuminated surfaces
  113273. */
  113274. brightThreshold: number;
  113275. /**
  113276. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113277. */
  113278. blurWidth: number;
  113279. /**
  113280. * Sets if the blur for highlighted surfaces must be only horizontal
  113281. */
  113282. horizontalBlur: boolean;
  113283. /**
  113284. * Gets the overall exposure used by the pipeline
  113285. */
  113286. /**
  113287. * Sets the overall exposure used by the pipeline
  113288. */
  113289. exposure: number;
  113290. /**
  113291. * Texture used typically to simulate "dirty" on camera lens
  113292. */
  113293. lensTexture: Nullable<Texture>;
  113294. /**
  113295. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113296. */
  113297. volumetricLightCoefficient: number;
  113298. /**
  113299. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113300. */
  113301. volumetricLightPower: number;
  113302. /**
  113303. * Used the set the blur intensity to smooth the volumetric lights
  113304. */
  113305. volumetricLightBlurScale: number;
  113306. /**
  113307. * Light (spot or directional) used to generate the volumetric lights rays
  113308. * The source light must have a shadow generate so the pipeline can get its
  113309. * depth map
  113310. */
  113311. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113312. /**
  113313. * For eye adaptation, represents the minimum luminance the eye can see
  113314. */
  113315. hdrMinimumLuminance: number;
  113316. /**
  113317. * For eye adaptation, represents the decrease luminance speed
  113318. */
  113319. hdrDecreaseRate: number;
  113320. /**
  113321. * For eye adaptation, represents the increase luminance speed
  113322. */
  113323. hdrIncreaseRate: number;
  113324. /**
  113325. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113326. */
  113327. /**
  113328. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113329. */
  113330. hdrAutoExposure: boolean;
  113331. /**
  113332. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113333. */
  113334. lensColorTexture: Nullable<Texture>;
  113335. /**
  113336. * The overall strengh for the lens flare effect
  113337. */
  113338. lensFlareStrength: number;
  113339. /**
  113340. * Dispersion coefficient for lens flare ghosts
  113341. */
  113342. lensFlareGhostDispersal: number;
  113343. /**
  113344. * Main lens flare halo width
  113345. */
  113346. lensFlareHaloWidth: number;
  113347. /**
  113348. * Based on the lens distortion effect, defines how much the lens flare result
  113349. * is distorted
  113350. */
  113351. lensFlareDistortionStrength: number;
  113352. /**
  113353. * Lens star texture must be used to simulate rays on the flares and is available
  113354. * in the documentation
  113355. */
  113356. lensStarTexture: Nullable<Texture>;
  113357. /**
  113358. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113359. * flare effect by taking account of the dirt texture
  113360. */
  113361. lensFlareDirtTexture: Nullable<Texture>;
  113362. /**
  113363. * Represents the focal length for the depth of field effect
  113364. */
  113365. depthOfFieldDistance: number;
  113366. /**
  113367. * Represents the blur intensity for the blurred part of the depth of field effect
  113368. */
  113369. depthOfFieldBlurWidth: number;
  113370. /**
  113371. * For motion blur, defines how much the image is blurred by the movement
  113372. */
  113373. motionStrength: number;
  113374. /**
  113375. * List of animations for the pipeline (IAnimatable implementation)
  113376. */
  113377. animations: Animation[];
  113378. /**
  113379. * Private members
  113380. */
  113381. private _scene;
  113382. private _currentDepthOfFieldSource;
  113383. private _basePostProcess;
  113384. private _fixedExposure;
  113385. private _currentExposure;
  113386. private _hdrAutoExposure;
  113387. private _hdrCurrentLuminance;
  113388. private _floatTextureType;
  113389. private _ratio;
  113390. private _bloomEnabled;
  113391. private _depthOfFieldEnabled;
  113392. private _vlsEnabled;
  113393. private _lensFlareEnabled;
  113394. private _hdrEnabled;
  113395. private _motionBlurEnabled;
  113396. private _fxaaEnabled;
  113397. private _motionBlurSamples;
  113398. private _volumetricLightStepsCount;
  113399. private _samples;
  113400. /**
  113401. * @ignore
  113402. * Specifies if the bloom pipeline is enabled
  113403. */
  113404. BloomEnabled: boolean;
  113405. /**
  113406. * @ignore
  113407. * Specifies if the depth of field pipeline is enabed
  113408. */
  113409. DepthOfFieldEnabled: boolean;
  113410. /**
  113411. * @ignore
  113412. * Specifies if the lens flare pipeline is enabed
  113413. */
  113414. LensFlareEnabled: boolean;
  113415. /**
  113416. * @ignore
  113417. * Specifies if the HDR pipeline is enabled
  113418. */
  113419. HDREnabled: boolean;
  113420. /**
  113421. * @ignore
  113422. * Specifies if the volumetric lights scattering effect is enabled
  113423. */
  113424. VLSEnabled: boolean;
  113425. /**
  113426. * @ignore
  113427. * Specifies if the motion blur effect is enabled
  113428. */
  113429. MotionBlurEnabled: boolean;
  113430. /**
  113431. * Specifies if anti-aliasing is enabled
  113432. */
  113433. fxaaEnabled: boolean;
  113434. /**
  113435. * Specifies the number of steps used to calculate the volumetric lights
  113436. * Typically in interval [50, 200]
  113437. */
  113438. volumetricLightStepsCount: number;
  113439. /**
  113440. * Specifies the number of samples used for the motion blur effect
  113441. * Typically in interval [16, 64]
  113442. */
  113443. motionBlurSamples: number;
  113444. /**
  113445. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113446. */
  113447. samples: number;
  113448. /**
  113449. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113450. * @constructor
  113451. * @param name The rendering pipeline name
  113452. * @param scene The scene linked to this pipeline
  113453. * @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)
  113454. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113455. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113456. */
  113457. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113458. private _buildPipeline;
  113459. private _createDownSampleX4PostProcess;
  113460. private _createBrightPassPostProcess;
  113461. private _createBlurPostProcesses;
  113462. private _createTextureAdderPostProcess;
  113463. private _createVolumetricLightPostProcess;
  113464. private _createLuminancePostProcesses;
  113465. private _createHdrPostProcess;
  113466. private _createLensFlarePostProcess;
  113467. private _createDepthOfFieldPostProcess;
  113468. private _createMotionBlurPostProcess;
  113469. private _getDepthTexture;
  113470. private _disposePostProcesses;
  113471. /**
  113472. * Dispose of the pipeline and stop all post processes
  113473. */
  113474. dispose(): void;
  113475. /**
  113476. * Serialize the rendering pipeline (Used when exporting)
  113477. * @returns the serialized object
  113478. */
  113479. serialize(): any;
  113480. /**
  113481. * Parse the serialized pipeline
  113482. * @param source Source pipeline.
  113483. * @param scene The scene to load the pipeline to.
  113484. * @param rootUrl The URL of the serialized pipeline.
  113485. * @returns An instantiated pipeline from the serialized object.
  113486. */
  113487. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113488. /**
  113489. * Luminance steps
  113490. */
  113491. static LuminanceSteps: number;
  113492. }
  113493. }
  113494. declare module BABYLON {
  113495. /** @hidden */
  113496. export var tonemapPixelShader: {
  113497. name: string;
  113498. shader: string;
  113499. };
  113500. }
  113501. declare module BABYLON {
  113502. /** Defines operator used for tonemapping */
  113503. export enum TonemappingOperator {
  113504. /** Hable */
  113505. Hable = 0,
  113506. /** Reinhard */
  113507. Reinhard = 1,
  113508. /** HejiDawson */
  113509. HejiDawson = 2,
  113510. /** Photographic */
  113511. Photographic = 3
  113512. }
  113513. /**
  113514. * Defines a post process to apply tone mapping
  113515. */
  113516. export class TonemapPostProcess extends PostProcess {
  113517. private _operator;
  113518. /** Defines the required exposure adjustement */
  113519. exposureAdjustment: number;
  113520. /**
  113521. * Creates a new TonemapPostProcess
  113522. * @param name defines the name of the postprocess
  113523. * @param _operator defines the operator to use
  113524. * @param exposureAdjustment defines the required exposure adjustement
  113525. * @param camera defines the camera to use (can be null)
  113526. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113527. * @param engine defines the hosting engine (can be ignore if camera is set)
  113528. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113529. */
  113530. constructor(name: string, _operator: TonemappingOperator,
  113531. /** Defines the required exposure adjustement */
  113532. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113533. }
  113534. }
  113535. declare module BABYLON {
  113536. /** @hidden */
  113537. export var depthVertexShader: {
  113538. name: string;
  113539. shader: string;
  113540. };
  113541. }
  113542. declare module BABYLON {
  113543. /** @hidden */
  113544. export var volumetricLightScatteringPixelShader: {
  113545. name: string;
  113546. shader: string;
  113547. };
  113548. }
  113549. declare module BABYLON {
  113550. /** @hidden */
  113551. export var volumetricLightScatteringPassPixelShader: {
  113552. name: string;
  113553. shader: string;
  113554. };
  113555. }
  113556. declare module BABYLON {
  113557. /**
  113558. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113559. */
  113560. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113561. private _volumetricLightScatteringPass;
  113562. private _volumetricLightScatteringRTT;
  113563. private _viewPort;
  113564. private _screenCoordinates;
  113565. private _cachedDefines;
  113566. /**
  113567. * If not undefined, the mesh position is computed from the attached node position
  113568. */
  113569. attachedNode: {
  113570. position: Vector3;
  113571. };
  113572. /**
  113573. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113574. */
  113575. customMeshPosition: Vector3;
  113576. /**
  113577. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113578. */
  113579. useCustomMeshPosition: boolean;
  113580. /**
  113581. * If the post-process should inverse the light scattering direction
  113582. */
  113583. invert: boolean;
  113584. /**
  113585. * The internal mesh used by the post-process
  113586. */
  113587. mesh: Mesh;
  113588. /**
  113589. * @hidden
  113590. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113591. */
  113592. useDiffuseColor: boolean;
  113593. /**
  113594. * Array containing the excluded meshes not rendered in the internal pass
  113595. */
  113596. excludedMeshes: AbstractMesh[];
  113597. /**
  113598. * Controls the overall intensity of the post-process
  113599. */
  113600. exposure: number;
  113601. /**
  113602. * Dissipates each sample's contribution in range [0, 1]
  113603. */
  113604. decay: number;
  113605. /**
  113606. * Controls the overall intensity of each sample
  113607. */
  113608. weight: number;
  113609. /**
  113610. * Controls the density of each sample
  113611. */
  113612. density: number;
  113613. /**
  113614. * @constructor
  113615. * @param name The post-process name
  113616. * @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)
  113617. * @param camera The camera that the post-process will be attached to
  113618. * @param mesh The mesh used to create the light scattering
  113619. * @param samples The post-process quality, default 100
  113620. * @param samplingModeThe post-process filtering mode
  113621. * @param engine The babylon engine
  113622. * @param reusable If the post-process is reusable
  113623. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113624. */
  113625. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113626. /**
  113627. * Returns the string "VolumetricLightScatteringPostProcess"
  113628. * @returns "VolumetricLightScatteringPostProcess"
  113629. */
  113630. getClassName(): string;
  113631. private _isReady;
  113632. /**
  113633. * Sets the new light position for light scattering effect
  113634. * @param position The new custom light position
  113635. */
  113636. setCustomMeshPosition(position: Vector3): void;
  113637. /**
  113638. * Returns the light position for light scattering effect
  113639. * @return Vector3 The custom light position
  113640. */
  113641. getCustomMeshPosition(): Vector3;
  113642. /**
  113643. * Disposes the internal assets and detaches the post-process from the camera
  113644. */
  113645. dispose(camera: Camera): void;
  113646. /**
  113647. * Returns the render target texture used by the post-process
  113648. * @return the render target texture used by the post-process
  113649. */
  113650. getPass(): RenderTargetTexture;
  113651. private _meshExcluded;
  113652. private _createPass;
  113653. private _updateMeshScreenCoordinates;
  113654. /**
  113655. * Creates a default mesh for the Volumeric Light Scattering post-process
  113656. * @param name The mesh name
  113657. * @param scene The scene where to create the mesh
  113658. * @return the default mesh
  113659. */
  113660. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113661. }
  113662. }
  113663. declare module BABYLON {
  113664. interface Scene {
  113665. /** @hidden (Backing field) */
  113666. _boundingBoxRenderer: BoundingBoxRenderer;
  113667. /** @hidden (Backing field) */
  113668. _forceShowBoundingBoxes: boolean;
  113669. /**
  113670. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113671. */
  113672. forceShowBoundingBoxes: boolean;
  113673. /**
  113674. * Gets the bounding box renderer associated with the scene
  113675. * @returns a BoundingBoxRenderer
  113676. */
  113677. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113678. }
  113679. interface AbstractMesh {
  113680. /** @hidden (Backing field) */
  113681. _showBoundingBox: boolean;
  113682. /**
  113683. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113684. */
  113685. showBoundingBox: boolean;
  113686. }
  113687. /**
  113688. * Component responsible of rendering the bounding box of the meshes in a scene.
  113689. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113690. */
  113691. export class BoundingBoxRenderer implements ISceneComponent {
  113692. /**
  113693. * The component name helpfull to identify the component in the list of scene components.
  113694. */
  113695. readonly name: string;
  113696. /**
  113697. * The scene the component belongs to.
  113698. */
  113699. scene: Scene;
  113700. /**
  113701. * Color of the bounding box lines placed in front of an object
  113702. */
  113703. frontColor: Color3;
  113704. /**
  113705. * Color of the bounding box lines placed behind an object
  113706. */
  113707. backColor: Color3;
  113708. /**
  113709. * Defines if the renderer should show the back lines or not
  113710. */
  113711. showBackLines: boolean;
  113712. /**
  113713. * @hidden
  113714. */
  113715. renderList: SmartArray<BoundingBox>;
  113716. private _colorShader;
  113717. private _vertexBuffers;
  113718. private _indexBuffer;
  113719. /**
  113720. * Instantiates a new bounding box renderer in a scene.
  113721. * @param scene the scene the renderer renders in
  113722. */
  113723. constructor(scene: Scene);
  113724. /**
  113725. * Registers the component in a given scene
  113726. */
  113727. register(): void;
  113728. private _evaluateSubMesh;
  113729. private _activeMesh;
  113730. private _prepareRessources;
  113731. private _createIndexBuffer;
  113732. /**
  113733. * Rebuilds the elements related to this component in case of
  113734. * context lost for instance.
  113735. */
  113736. rebuild(): void;
  113737. /**
  113738. * @hidden
  113739. */
  113740. reset(): void;
  113741. /**
  113742. * Render the bounding boxes of a specific rendering group
  113743. * @param renderingGroupId defines the rendering group to render
  113744. */
  113745. render(renderingGroupId: number): void;
  113746. /**
  113747. * In case of occlusion queries, we can render the occlusion bounding box through this method
  113748. * @param mesh Define the mesh to render the occlusion bounding box for
  113749. */
  113750. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  113751. /**
  113752. * Dispose and release the resources attached to this renderer.
  113753. */
  113754. dispose(): void;
  113755. }
  113756. }
  113757. declare module BABYLON {
  113758. /** @hidden */
  113759. export var depthPixelShader: {
  113760. name: string;
  113761. shader: string;
  113762. };
  113763. }
  113764. declare module BABYLON {
  113765. /**
  113766. * This represents a depth renderer in Babylon.
  113767. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  113768. */
  113769. export class DepthRenderer {
  113770. private _scene;
  113771. private _depthMap;
  113772. private _effect;
  113773. private _cachedDefines;
  113774. private _camera;
  113775. /**
  113776. * Specifiess that the depth renderer will only be used within
  113777. * the camera it is created for.
  113778. * This can help forcing its rendering during the camera processing.
  113779. */
  113780. useOnlyInActiveCamera: boolean;
  113781. /** @hidden */
  113782. static _SceneComponentInitialization: (scene: Scene) => void;
  113783. /**
  113784. * Instantiates a depth renderer
  113785. * @param scene The scene the renderer belongs to
  113786. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  113787. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  113788. */
  113789. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  113790. /**
  113791. * Creates the depth rendering effect and checks if the effect is ready.
  113792. * @param subMesh The submesh to be used to render the depth map of
  113793. * @param useInstances If multiple world instances should be used
  113794. * @returns if the depth renderer is ready to render the depth map
  113795. */
  113796. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113797. /**
  113798. * Gets the texture which the depth map will be written to.
  113799. * @returns The depth map texture
  113800. */
  113801. getDepthMap(): RenderTargetTexture;
  113802. /**
  113803. * Disposes of the depth renderer.
  113804. */
  113805. dispose(): void;
  113806. }
  113807. }
  113808. declare module BABYLON {
  113809. interface Scene {
  113810. /** @hidden (Backing field) */
  113811. _depthRenderer: {
  113812. [id: string]: DepthRenderer;
  113813. };
  113814. /**
  113815. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  113816. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  113817. * @returns the created depth renderer
  113818. */
  113819. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  113820. /**
  113821. * Disables a depth renderer for a given camera
  113822. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  113823. */
  113824. disableDepthRenderer(camera?: Nullable<Camera>): void;
  113825. }
  113826. /**
  113827. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  113828. * in several rendering techniques.
  113829. */
  113830. export class DepthRendererSceneComponent implements ISceneComponent {
  113831. /**
  113832. * The component name helpfull to identify the component in the list of scene components.
  113833. */
  113834. readonly name: string;
  113835. /**
  113836. * The scene the component belongs to.
  113837. */
  113838. scene: Scene;
  113839. /**
  113840. * Creates a new instance of the component for the given scene
  113841. * @param scene Defines the scene to register the component in
  113842. */
  113843. constructor(scene: Scene);
  113844. /**
  113845. * Registers the component in a given scene
  113846. */
  113847. register(): void;
  113848. /**
  113849. * Rebuilds the elements related to this component in case of
  113850. * context lost for instance.
  113851. */
  113852. rebuild(): void;
  113853. /**
  113854. * Disposes the component and the associated ressources
  113855. */
  113856. dispose(): void;
  113857. private _gatherRenderTargets;
  113858. private _gatherActiveCameraRenderTargets;
  113859. }
  113860. }
  113861. declare module BABYLON {
  113862. /** @hidden */
  113863. export var outlinePixelShader: {
  113864. name: string;
  113865. shader: string;
  113866. };
  113867. }
  113868. declare module BABYLON {
  113869. /** @hidden */
  113870. export var outlineVertexShader: {
  113871. name: string;
  113872. shader: string;
  113873. };
  113874. }
  113875. declare module BABYLON {
  113876. interface Scene {
  113877. /** @hidden */
  113878. _outlineRenderer: OutlineRenderer;
  113879. /**
  113880. * Gets the outline renderer associated with the scene
  113881. * @returns a OutlineRenderer
  113882. */
  113883. getOutlineRenderer(): OutlineRenderer;
  113884. }
  113885. interface AbstractMesh {
  113886. /** @hidden (Backing field) */
  113887. _renderOutline: boolean;
  113888. /**
  113889. * Gets or sets a boolean indicating if the outline must be rendered as well
  113890. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  113891. */
  113892. renderOutline: boolean;
  113893. /** @hidden (Backing field) */
  113894. _renderOverlay: boolean;
  113895. /**
  113896. * Gets or sets a boolean indicating if the overlay must be rendered as well
  113897. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  113898. */
  113899. renderOverlay: boolean;
  113900. }
  113901. /**
  113902. * This class is responsible to draw bothe outline/overlay of meshes.
  113903. * It should not be used directly but through the available method on mesh.
  113904. */
  113905. export class OutlineRenderer implements ISceneComponent {
  113906. /**
  113907. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  113908. */
  113909. private static _StencilReference;
  113910. /**
  113911. * The name of the component. Each component must have a unique name.
  113912. */
  113913. name: string;
  113914. /**
  113915. * The scene the component belongs to.
  113916. */
  113917. scene: Scene;
  113918. /**
  113919. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  113920. */
  113921. zOffset: number;
  113922. private _engine;
  113923. private _effect;
  113924. private _cachedDefines;
  113925. private _savedDepthWrite;
  113926. /**
  113927. * Instantiates a new outline renderer. (There could be only one per scene).
  113928. * @param scene Defines the scene it belongs to
  113929. */
  113930. constructor(scene: Scene);
  113931. /**
  113932. * Register the component to one instance of a scene.
  113933. */
  113934. register(): void;
  113935. /**
  113936. * Rebuilds the elements related to this component in case of
  113937. * context lost for instance.
  113938. */
  113939. rebuild(): void;
  113940. /**
  113941. * Disposes the component and the associated ressources.
  113942. */
  113943. dispose(): void;
  113944. /**
  113945. * Renders the outline in the canvas.
  113946. * @param subMesh Defines the sumesh to render
  113947. * @param batch Defines the batch of meshes in case of instances
  113948. * @param useOverlay Defines if the rendering is for the overlay or the outline
  113949. */
  113950. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  113951. /**
  113952. * Returns whether or not the outline renderer is ready for a given submesh.
  113953. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  113954. * @param subMesh Defines the submesh to check readyness for
  113955. * @param useInstances Defines wheter wee are trying to render instances or not
  113956. * @returns true if ready otherwise false
  113957. */
  113958. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  113959. private _beforeRenderingMesh;
  113960. private _afterRenderingMesh;
  113961. }
  113962. }
  113963. declare module BABYLON {
  113964. /**
  113965. * Defines the list of states available for a task inside a AssetsManager
  113966. */
  113967. export enum AssetTaskState {
  113968. /**
  113969. * Initialization
  113970. */
  113971. INIT = 0,
  113972. /**
  113973. * Running
  113974. */
  113975. RUNNING = 1,
  113976. /**
  113977. * Done
  113978. */
  113979. DONE = 2,
  113980. /**
  113981. * Error
  113982. */
  113983. ERROR = 3
  113984. }
  113985. /**
  113986. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  113987. */
  113988. export abstract class AbstractAssetTask {
  113989. /**
  113990. * Task name
  113991. */ name: string;
  113992. /**
  113993. * Callback called when the task is successful
  113994. */
  113995. onSuccess: (task: any) => void;
  113996. /**
  113997. * Callback called when the task is not successful
  113998. */
  113999. onError: (task: any, message?: string, exception?: any) => void;
  114000. /**
  114001. * Creates a new AssetsManager
  114002. * @param name defines the name of the task
  114003. */
  114004. constructor(
  114005. /**
  114006. * Task name
  114007. */ name: string);
  114008. private _isCompleted;
  114009. private _taskState;
  114010. private _errorObject;
  114011. /**
  114012. * Get if the task is completed
  114013. */
  114014. readonly isCompleted: boolean;
  114015. /**
  114016. * Gets the current state of the task
  114017. */
  114018. readonly taskState: AssetTaskState;
  114019. /**
  114020. * Gets the current error object (if task is in error)
  114021. */
  114022. readonly errorObject: {
  114023. message?: string;
  114024. exception?: any;
  114025. };
  114026. /**
  114027. * Internal only
  114028. * @hidden
  114029. */
  114030. _setErrorObject(message?: string, exception?: any): void;
  114031. /**
  114032. * Execute the current task
  114033. * @param scene defines the scene where you want your assets to be loaded
  114034. * @param onSuccess is a callback called when the task is successfully executed
  114035. * @param onError is a callback called if an error occurs
  114036. */
  114037. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114038. /**
  114039. * Execute the current task
  114040. * @param scene defines the scene where you want your assets to be loaded
  114041. * @param onSuccess is a callback called when the task is successfully executed
  114042. * @param onError is a callback called if an error occurs
  114043. */
  114044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114045. /**
  114046. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114047. * This can be used with failed tasks that have the reason for failure fixed.
  114048. */
  114049. reset(): void;
  114050. private onErrorCallback;
  114051. private onDoneCallback;
  114052. }
  114053. /**
  114054. * Define the interface used by progress events raised during assets loading
  114055. */
  114056. export interface IAssetsProgressEvent {
  114057. /**
  114058. * Defines the number of remaining tasks to process
  114059. */
  114060. remainingCount: number;
  114061. /**
  114062. * Defines the total number of tasks
  114063. */
  114064. totalCount: number;
  114065. /**
  114066. * Defines the task that was just processed
  114067. */
  114068. task: AbstractAssetTask;
  114069. }
  114070. /**
  114071. * Class used to share progress information about assets loading
  114072. */
  114073. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114074. /**
  114075. * Defines the number of remaining tasks to process
  114076. */
  114077. remainingCount: number;
  114078. /**
  114079. * Defines the total number of tasks
  114080. */
  114081. totalCount: number;
  114082. /**
  114083. * Defines the task that was just processed
  114084. */
  114085. task: AbstractAssetTask;
  114086. /**
  114087. * Creates a AssetsProgressEvent
  114088. * @param remainingCount defines the number of remaining tasks to process
  114089. * @param totalCount defines the total number of tasks
  114090. * @param task defines the task that was just processed
  114091. */
  114092. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114093. }
  114094. /**
  114095. * Define a task used by AssetsManager to load meshes
  114096. */
  114097. export class MeshAssetTask extends AbstractAssetTask {
  114098. /**
  114099. * Defines the name of the task
  114100. */
  114101. name: string;
  114102. /**
  114103. * Defines the list of mesh's names you want to load
  114104. */
  114105. meshesNames: any;
  114106. /**
  114107. * Defines the root url to use as a base to load your meshes and associated resources
  114108. */
  114109. rootUrl: string;
  114110. /**
  114111. * Defines the filename of the scene to load from
  114112. */
  114113. sceneFilename: string;
  114114. /**
  114115. * Gets the list of loaded meshes
  114116. */
  114117. loadedMeshes: Array<AbstractMesh>;
  114118. /**
  114119. * Gets the list of loaded particle systems
  114120. */
  114121. loadedParticleSystems: Array<IParticleSystem>;
  114122. /**
  114123. * Gets the list of loaded skeletons
  114124. */
  114125. loadedSkeletons: Array<Skeleton>;
  114126. /**
  114127. * Gets the list of loaded animation groups
  114128. */
  114129. loadedAnimationGroups: Array<AnimationGroup>;
  114130. /**
  114131. * Callback called when the task is successful
  114132. */
  114133. onSuccess: (task: MeshAssetTask) => void;
  114134. /**
  114135. * Callback called when the task is successful
  114136. */
  114137. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114138. /**
  114139. * Creates a new MeshAssetTask
  114140. * @param name defines the name of the task
  114141. * @param meshesNames defines the list of mesh's names you want to load
  114142. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114143. * @param sceneFilename defines the filename of the scene to load from
  114144. */
  114145. constructor(
  114146. /**
  114147. * Defines the name of the task
  114148. */
  114149. name: string,
  114150. /**
  114151. * Defines the list of mesh's names you want to load
  114152. */
  114153. meshesNames: any,
  114154. /**
  114155. * Defines the root url to use as a base to load your meshes and associated resources
  114156. */
  114157. rootUrl: string,
  114158. /**
  114159. * Defines the filename of the scene to load from
  114160. */
  114161. sceneFilename: string);
  114162. /**
  114163. * Execute the current task
  114164. * @param scene defines the scene where you want your assets to be loaded
  114165. * @param onSuccess is a callback called when the task is successfully executed
  114166. * @param onError is a callback called if an error occurs
  114167. */
  114168. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114169. }
  114170. /**
  114171. * Define a task used by AssetsManager to load text content
  114172. */
  114173. export class TextFileAssetTask extends AbstractAssetTask {
  114174. /**
  114175. * Defines the name of the task
  114176. */
  114177. name: string;
  114178. /**
  114179. * Defines the location of the file to load
  114180. */
  114181. url: string;
  114182. /**
  114183. * Gets the loaded text string
  114184. */
  114185. text: string;
  114186. /**
  114187. * Callback called when the task is successful
  114188. */
  114189. onSuccess: (task: TextFileAssetTask) => void;
  114190. /**
  114191. * Callback called when the task is successful
  114192. */
  114193. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114194. /**
  114195. * Creates a new TextFileAssetTask object
  114196. * @param name defines the name of the task
  114197. * @param url defines the location of the file to load
  114198. */
  114199. constructor(
  114200. /**
  114201. * Defines the name of the task
  114202. */
  114203. name: string,
  114204. /**
  114205. * Defines the location of the file to load
  114206. */
  114207. url: string);
  114208. /**
  114209. * Execute the current task
  114210. * @param scene defines the scene where you want your assets to be loaded
  114211. * @param onSuccess is a callback called when the task is successfully executed
  114212. * @param onError is a callback called if an error occurs
  114213. */
  114214. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114215. }
  114216. /**
  114217. * Define a task used by AssetsManager to load binary data
  114218. */
  114219. export class BinaryFileAssetTask extends AbstractAssetTask {
  114220. /**
  114221. * Defines the name of the task
  114222. */
  114223. name: string;
  114224. /**
  114225. * Defines the location of the file to load
  114226. */
  114227. url: string;
  114228. /**
  114229. * Gets the lodaded data (as an array buffer)
  114230. */
  114231. data: ArrayBuffer;
  114232. /**
  114233. * Callback called when the task is successful
  114234. */
  114235. onSuccess: (task: BinaryFileAssetTask) => void;
  114236. /**
  114237. * Callback called when the task is successful
  114238. */
  114239. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114240. /**
  114241. * Creates a new BinaryFileAssetTask object
  114242. * @param name defines the name of the new task
  114243. * @param url defines the location of the file to load
  114244. */
  114245. constructor(
  114246. /**
  114247. * Defines the name of the task
  114248. */
  114249. name: string,
  114250. /**
  114251. * Defines the location of the file to load
  114252. */
  114253. url: string);
  114254. /**
  114255. * Execute the current task
  114256. * @param scene defines the scene where you want your assets to be loaded
  114257. * @param onSuccess is a callback called when the task is successfully executed
  114258. * @param onError is a callback called if an error occurs
  114259. */
  114260. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114261. }
  114262. /**
  114263. * Define a task used by AssetsManager to load images
  114264. */
  114265. export class ImageAssetTask extends AbstractAssetTask {
  114266. /**
  114267. * Defines the name of the task
  114268. */
  114269. name: string;
  114270. /**
  114271. * Defines the location of the image to load
  114272. */
  114273. url: string;
  114274. /**
  114275. * Gets the loaded images
  114276. */
  114277. image: HTMLImageElement;
  114278. /**
  114279. * Callback called when the task is successful
  114280. */
  114281. onSuccess: (task: ImageAssetTask) => void;
  114282. /**
  114283. * Callback called when the task is successful
  114284. */
  114285. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114286. /**
  114287. * Creates a new ImageAssetTask
  114288. * @param name defines the name of the task
  114289. * @param url defines the location of the image to load
  114290. */
  114291. constructor(
  114292. /**
  114293. * Defines the name of the task
  114294. */
  114295. name: string,
  114296. /**
  114297. * Defines the location of the image to load
  114298. */
  114299. url: string);
  114300. /**
  114301. * Execute the current task
  114302. * @param scene defines the scene where you want your assets to be loaded
  114303. * @param onSuccess is a callback called when the task is successfully executed
  114304. * @param onError is a callback called if an error occurs
  114305. */
  114306. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114307. }
  114308. /**
  114309. * Defines the interface used by texture loading tasks
  114310. */
  114311. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114312. /**
  114313. * Gets the loaded texture
  114314. */
  114315. texture: TEX;
  114316. }
  114317. /**
  114318. * Define a task used by AssetsManager to load 2D textures
  114319. */
  114320. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114321. /**
  114322. * Defines the name of the task
  114323. */
  114324. name: string;
  114325. /**
  114326. * Defines the location of the file to load
  114327. */
  114328. url: string;
  114329. /**
  114330. * Defines if mipmap should not be generated (default is false)
  114331. */
  114332. noMipmap?: boolean | undefined;
  114333. /**
  114334. * Defines if texture must be inverted on Y axis (default is false)
  114335. */
  114336. invertY?: boolean | undefined;
  114337. /**
  114338. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114339. */
  114340. samplingMode: number;
  114341. /**
  114342. * Gets the loaded texture
  114343. */
  114344. texture: Texture;
  114345. /**
  114346. * Callback called when the task is successful
  114347. */
  114348. onSuccess: (task: TextureAssetTask) => void;
  114349. /**
  114350. * Callback called when the task is successful
  114351. */
  114352. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114353. /**
  114354. * Creates a new TextureAssetTask object
  114355. * @param name defines the name of the task
  114356. * @param url defines the location of the file to load
  114357. * @param noMipmap defines if mipmap should not be generated (default is false)
  114358. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114359. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114360. */
  114361. constructor(
  114362. /**
  114363. * Defines the name of the task
  114364. */
  114365. name: string,
  114366. /**
  114367. * Defines the location of the file to load
  114368. */
  114369. url: string,
  114370. /**
  114371. * Defines if mipmap should not be generated (default is false)
  114372. */
  114373. noMipmap?: boolean | undefined,
  114374. /**
  114375. * Defines if texture must be inverted on Y axis (default is false)
  114376. */
  114377. invertY?: boolean | undefined,
  114378. /**
  114379. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114380. */
  114381. samplingMode?: number);
  114382. /**
  114383. * Execute the current task
  114384. * @param scene defines the scene where you want your assets to be loaded
  114385. * @param onSuccess is a callback called when the task is successfully executed
  114386. * @param onError is a callback called if an error occurs
  114387. */
  114388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114389. }
  114390. /**
  114391. * Define a task used by AssetsManager to load cube textures
  114392. */
  114393. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114394. /**
  114395. * Defines the name of the task
  114396. */
  114397. name: string;
  114398. /**
  114399. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114400. */
  114401. url: string;
  114402. /**
  114403. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114404. */
  114405. extensions?: string[] | undefined;
  114406. /**
  114407. * Defines if mipmaps should not be generated (default is false)
  114408. */
  114409. noMipmap?: boolean | undefined;
  114410. /**
  114411. * Defines the explicit list of files (undefined by default)
  114412. */
  114413. files?: string[] | undefined;
  114414. /**
  114415. * Gets the loaded texture
  114416. */
  114417. texture: CubeTexture;
  114418. /**
  114419. * Callback called when the task is successful
  114420. */
  114421. onSuccess: (task: CubeTextureAssetTask) => void;
  114422. /**
  114423. * Callback called when the task is successful
  114424. */
  114425. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114426. /**
  114427. * Creates a new CubeTextureAssetTask
  114428. * @param name defines the name of the task
  114429. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114430. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114431. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114432. * @param files defines the explicit list of files (undefined by default)
  114433. */
  114434. constructor(
  114435. /**
  114436. * Defines the name of the task
  114437. */
  114438. name: string,
  114439. /**
  114440. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114441. */
  114442. url: string,
  114443. /**
  114444. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114445. */
  114446. extensions?: string[] | undefined,
  114447. /**
  114448. * Defines if mipmaps should not be generated (default is false)
  114449. */
  114450. noMipmap?: boolean | undefined,
  114451. /**
  114452. * Defines the explicit list of files (undefined by default)
  114453. */
  114454. files?: string[] | undefined);
  114455. /**
  114456. * Execute the current task
  114457. * @param scene defines the scene where you want your assets to be loaded
  114458. * @param onSuccess is a callback called when the task is successfully executed
  114459. * @param onError is a callback called if an error occurs
  114460. */
  114461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114462. }
  114463. /**
  114464. * Define a task used by AssetsManager to load HDR cube textures
  114465. */
  114466. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114467. /**
  114468. * Defines the name of the task
  114469. */
  114470. name: string;
  114471. /**
  114472. * Defines the location of the file to load
  114473. */
  114474. url: string;
  114475. /**
  114476. * Defines the desired size (the more it increases the longer the generation will be)
  114477. */
  114478. size: number;
  114479. /**
  114480. * Defines if mipmaps should not be generated (default is false)
  114481. */
  114482. noMipmap: boolean;
  114483. /**
  114484. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114485. */
  114486. generateHarmonics: boolean;
  114487. /**
  114488. * 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)
  114489. */
  114490. gammaSpace: boolean;
  114491. /**
  114492. * Internal Use Only
  114493. */
  114494. reserved: boolean;
  114495. /**
  114496. * Gets the loaded texture
  114497. */
  114498. texture: HDRCubeTexture;
  114499. /**
  114500. * Callback called when the task is successful
  114501. */
  114502. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114503. /**
  114504. * Callback called when the task is successful
  114505. */
  114506. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114507. /**
  114508. * Creates a new HDRCubeTextureAssetTask object
  114509. * @param name defines the name of the task
  114510. * @param url defines the location of the file to load
  114511. * @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.
  114512. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114513. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114514. * @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)
  114515. * @param reserved Internal use only
  114516. */
  114517. constructor(
  114518. /**
  114519. * Defines the name of the task
  114520. */
  114521. name: string,
  114522. /**
  114523. * Defines the location of the file to load
  114524. */
  114525. url: string,
  114526. /**
  114527. * Defines the desired size (the more it increases the longer the generation will be)
  114528. */
  114529. size: number,
  114530. /**
  114531. * Defines if mipmaps should not be generated (default is false)
  114532. */
  114533. noMipmap?: boolean,
  114534. /**
  114535. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114536. */
  114537. generateHarmonics?: boolean,
  114538. /**
  114539. * 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)
  114540. */
  114541. gammaSpace?: boolean,
  114542. /**
  114543. * Internal Use Only
  114544. */
  114545. reserved?: boolean);
  114546. /**
  114547. * Execute the current task
  114548. * @param scene defines the scene where you want your assets to be loaded
  114549. * @param onSuccess is a callback called when the task is successfully executed
  114550. * @param onError is a callback called if an error occurs
  114551. */
  114552. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114553. }
  114554. /**
  114555. * Define a task used by AssetsManager to load Equirectangular cube textures
  114556. */
  114557. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114558. /**
  114559. * Defines the name of the task
  114560. */
  114561. name: string;
  114562. /**
  114563. * Defines the location of the file to load
  114564. */
  114565. url: string;
  114566. /**
  114567. * Defines the desired size (the more it increases the longer the generation will be)
  114568. */
  114569. size: number;
  114570. /**
  114571. * Defines if mipmaps should not be generated (default is false)
  114572. */
  114573. noMipmap: boolean;
  114574. /**
  114575. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114576. * but the standard material would require them in Gamma space) (default is true)
  114577. */
  114578. gammaSpace: boolean;
  114579. /**
  114580. * Gets the loaded texture
  114581. */
  114582. texture: EquiRectangularCubeTexture;
  114583. /**
  114584. * Callback called when the task is successful
  114585. */
  114586. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114587. /**
  114588. * Callback called when the task is successful
  114589. */
  114590. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114591. /**
  114592. * Creates a new EquiRectangularCubeTextureAssetTask object
  114593. * @param name defines the name of the task
  114594. * @param url defines the location of the file to load
  114595. * @param size defines the desired size (the more it increases the longer the generation will be)
  114596. * If the size is omitted this implies you are using a preprocessed cubemap.
  114597. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114598. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114599. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114600. * (default is true)
  114601. */
  114602. constructor(
  114603. /**
  114604. * Defines the name of the task
  114605. */
  114606. name: string,
  114607. /**
  114608. * Defines the location of the file to load
  114609. */
  114610. url: string,
  114611. /**
  114612. * Defines the desired size (the more it increases the longer the generation will be)
  114613. */
  114614. size: number,
  114615. /**
  114616. * Defines if mipmaps should not be generated (default is false)
  114617. */
  114618. noMipmap?: boolean,
  114619. /**
  114620. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114621. * but the standard material would require them in Gamma space) (default is true)
  114622. */
  114623. gammaSpace?: boolean);
  114624. /**
  114625. * Execute the current task
  114626. * @param scene defines the scene where you want your assets to be loaded
  114627. * @param onSuccess is a callback called when the task is successfully executed
  114628. * @param onError is a callback called if an error occurs
  114629. */
  114630. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114631. }
  114632. /**
  114633. * This class can be used to easily import assets into a scene
  114634. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114635. */
  114636. export class AssetsManager {
  114637. private _scene;
  114638. private _isLoading;
  114639. protected _tasks: AbstractAssetTask[];
  114640. protected _waitingTasksCount: number;
  114641. protected _totalTasksCount: number;
  114642. /**
  114643. * Callback called when all tasks are processed
  114644. */
  114645. onFinish: (tasks: AbstractAssetTask[]) => void;
  114646. /**
  114647. * Callback called when a task is successful
  114648. */
  114649. onTaskSuccess: (task: AbstractAssetTask) => void;
  114650. /**
  114651. * Callback called when a task had an error
  114652. */
  114653. onTaskError: (task: AbstractAssetTask) => void;
  114654. /**
  114655. * Callback called when a task is done (whatever the result is)
  114656. */
  114657. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114658. /**
  114659. * Observable called when all tasks are processed
  114660. */
  114661. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114662. /**
  114663. * Observable called when a task had an error
  114664. */
  114665. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114666. /**
  114667. * Observable called when all tasks were executed
  114668. */
  114669. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114670. /**
  114671. * Observable called when a task is done (whatever the result is)
  114672. */
  114673. onProgressObservable: Observable<IAssetsProgressEvent>;
  114674. /**
  114675. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114676. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114677. */
  114678. useDefaultLoadingScreen: boolean;
  114679. /**
  114680. * Creates a new AssetsManager
  114681. * @param scene defines the scene to work on
  114682. */
  114683. constructor(scene: Scene);
  114684. /**
  114685. * Add a MeshAssetTask to the list of active tasks
  114686. * @param taskName defines the name of the new task
  114687. * @param meshesNames defines the name of meshes to load
  114688. * @param rootUrl defines the root url to use to locate files
  114689. * @param sceneFilename defines the filename of the scene file
  114690. * @returns a new MeshAssetTask object
  114691. */
  114692. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114693. /**
  114694. * Add a TextFileAssetTask to the list of active tasks
  114695. * @param taskName defines the name of the new task
  114696. * @param url defines the url of the file to load
  114697. * @returns a new TextFileAssetTask object
  114698. */
  114699. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114700. /**
  114701. * Add a BinaryFileAssetTask to the list of active tasks
  114702. * @param taskName defines the name of the new task
  114703. * @param url defines the url of the file to load
  114704. * @returns a new BinaryFileAssetTask object
  114705. */
  114706. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114707. /**
  114708. * Add a ImageAssetTask to the list of active tasks
  114709. * @param taskName defines the name of the new task
  114710. * @param url defines the url of the file to load
  114711. * @returns a new ImageAssetTask object
  114712. */
  114713. addImageTask(taskName: string, url: string): ImageAssetTask;
  114714. /**
  114715. * Add a TextureAssetTask to the list of active tasks
  114716. * @param taskName defines the name of the new task
  114717. * @param url defines the url of the file to load
  114718. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114719. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114720. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114721. * @returns a new TextureAssetTask object
  114722. */
  114723. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114724. /**
  114725. * Add a CubeTextureAssetTask to the list of active tasks
  114726. * @param taskName defines the name of the new task
  114727. * @param url defines the url of the file to load
  114728. * @param extensions defines the extension to use to load the cube map (can be null)
  114729. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114730. * @param files defines the list of files to load (can be null)
  114731. * @returns a new CubeTextureAssetTask object
  114732. */
  114733. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114734. /**
  114735. *
  114736. * Add a HDRCubeTextureAssetTask to the list of active tasks
  114737. * @param taskName defines the name of the new task
  114738. * @param url defines the url of the file to load
  114739. * @param size defines the size you want for the cubemap (can be null)
  114740. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114741. * @param generateHarmonics defines if you want to automatically generate (true by default)
  114742. * @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)
  114743. * @param reserved Internal use only
  114744. * @returns a new HDRCubeTextureAssetTask object
  114745. */
  114746. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  114747. /**
  114748. *
  114749. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  114750. * @param taskName defines the name of the new task
  114751. * @param url defines the url of the file to load
  114752. * @param size defines the size you want for the cubemap (can be null)
  114753. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114754. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  114755. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  114756. * @returns a new EquiRectangularCubeTextureAssetTask object
  114757. */
  114758. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  114759. /**
  114760. * Remove a task from the assets manager.
  114761. * @param task the task to remove
  114762. */
  114763. removeTask(task: AbstractAssetTask): void;
  114764. private _decreaseWaitingTasksCount;
  114765. private _runTask;
  114766. /**
  114767. * Reset the AssetsManager and remove all tasks
  114768. * @return the current instance of the AssetsManager
  114769. */
  114770. reset(): AssetsManager;
  114771. /**
  114772. * Start the loading process
  114773. * @return the current instance of the AssetsManager
  114774. */
  114775. load(): AssetsManager;
  114776. /**
  114777. * Start the loading process as an async operation
  114778. * @return a promise returning the list of failed tasks
  114779. */
  114780. loadAsync(): Promise<void>;
  114781. }
  114782. }
  114783. declare module BABYLON {
  114784. /**
  114785. * Wrapper class for promise with external resolve and reject.
  114786. */
  114787. export class Deferred<T> {
  114788. /**
  114789. * The promise associated with this deferred object.
  114790. */
  114791. readonly promise: Promise<T>;
  114792. private _resolve;
  114793. private _reject;
  114794. /**
  114795. * The resolve method of the promise associated with this deferred object.
  114796. */
  114797. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  114798. /**
  114799. * The reject method of the promise associated with this deferred object.
  114800. */
  114801. readonly reject: (reason?: any) => void;
  114802. /**
  114803. * Constructor for this deferred object.
  114804. */
  114805. constructor();
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. /**
  114810. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  114811. */
  114812. export class MeshExploder {
  114813. private _centerMesh;
  114814. private _meshes;
  114815. private _meshesOrigins;
  114816. private _toCenterVectors;
  114817. private _scaledDirection;
  114818. private _newPosition;
  114819. private _centerPosition;
  114820. /**
  114821. * Explodes meshes from a center mesh.
  114822. * @param meshes The meshes to explode.
  114823. * @param centerMesh The mesh to be center of explosion.
  114824. */
  114825. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  114826. private _setCenterMesh;
  114827. /**
  114828. * Get class name
  114829. * @returns "MeshExploder"
  114830. */
  114831. getClassName(): string;
  114832. /**
  114833. * "Exploded meshes"
  114834. * @returns Array of meshes with the centerMesh at index 0.
  114835. */
  114836. getMeshes(): Array<Mesh>;
  114837. /**
  114838. * Explodes meshes giving a specific direction
  114839. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  114840. */
  114841. explode(direction?: number): void;
  114842. }
  114843. }
  114844. declare module BABYLON {
  114845. /**
  114846. * Class used to help managing file picking and drag'n'drop
  114847. */
  114848. export class FilesInput {
  114849. /**
  114850. * List of files ready to be loaded
  114851. */
  114852. static readonly FilesToLoad: {
  114853. [key: string]: File;
  114854. };
  114855. /**
  114856. * Callback called when a file is processed
  114857. */
  114858. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  114859. private _engine;
  114860. private _currentScene;
  114861. private _sceneLoadedCallback;
  114862. private _progressCallback;
  114863. private _additionalRenderLoopLogicCallback;
  114864. private _textureLoadingCallback;
  114865. private _startingProcessingFilesCallback;
  114866. private _onReloadCallback;
  114867. private _errorCallback;
  114868. private _elementToMonitor;
  114869. private _sceneFileToLoad;
  114870. private _filesToLoad;
  114871. /**
  114872. * Creates a new FilesInput
  114873. * @param engine defines the rendering engine
  114874. * @param scene defines the hosting scene
  114875. * @param sceneLoadedCallback callback called when scene is loaded
  114876. * @param progressCallback callback called to track progress
  114877. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  114878. * @param textureLoadingCallback callback called when a texture is loading
  114879. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  114880. * @param onReloadCallback callback called when a reload is requested
  114881. * @param errorCallback callback call if an error occurs
  114882. */
  114883. 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);
  114884. private _dragEnterHandler;
  114885. private _dragOverHandler;
  114886. private _dropHandler;
  114887. /**
  114888. * Calls this function to listen to drag'n'drop events on a specific DOM element
  114889. * @param elementToMonitor defines the DOM element to track
  114890. */
  114891. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  114892. /**
  114893. * Release all associated resources
  114894. */
  114895. dispose(): void;
  114896. private renderFunction;
  114897. private drag;
  114898. private drop;
  114899. private _traverseFolder;
  114900. private _processFiles;
  114901. /**
  114902. * Load files from a drop event
  114903. * @param event defines the drop event to use as source
  114904. */
  114905. loadFiles(event: any): void;
  114906. private _processReload;
  114907. /**
  114908. * Reload the current scene from the loaded files
  114909. */
  114910. reload(): void;
  114911. }
  114912. }
  114913. declare module BABYLON {
  114914. /**
  114915. * Defines the root class used to create scene optimization to use with SceneOptimizer
  114916. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114917. */
  114918. export class SceneOptimization {
  114919. /**
  114920. * Defines the priority of this optimization (0 by default which means first in the list)
  114921. */
  114922. priority: number;
  114923. /**
  114924. * Gets a string describing the action executed by the current optimization
  114925. * @returns description string
  114926. */
  114927. getDescription(): string;
  114928. /**
  114929. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114930. * @param scene defines the current scene where to apply this optimization
  114931. * @param optimizer defines the current optimizer
  114932. * @returns true if everything that can be done was applied
  114933. */
  114934. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114935. /**
  114936. * Creates the SceneOptimization object
  114937. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114938. * @param desc defines the description associated with the optimization
  114939. */
  114940. constructor(
  114941. /**
  114942. * Defines the priority of this optimization (0 by default which means first in the list)
  114943. */
  114944. priority?: number);
  114945. }
  114946. /**
  114947. * Defines an optimization used to reduce the size of render target textures
  114948. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114949. */
  114950. export class TextureOptimization extends SceneOptimization {
  114951. /**
  114952. * Defines the priority of this optimization (0 by default which means first in the list)
  114953. */
  114954. priority: number;
  114955. /**
  114956. * 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
  114957. */
  114958. maximumSize: number;
  114959. /**
  114960. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114961. */
  114962. step: number;
  114963. /**
  114964. * Gets a string describing the action executed by the current optimization
  114965. * @returns description string
  114966. */
  114967. getDescription(): string;
  114968. /**
  114969. * Creates the TextureOptimization object
  114970. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  114971. * @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
  114972. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114973. */
  114974. constructor(
  114975. /**
  114976. * Defines the priority of this optimization (0 by default which means first in the list)
  114977. */
  114978. priority?: number,
  114979. /**
  114980. * 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
  114981. */
  114982. maximumSize?: number,
  114983. /**
  114984. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  114985. */
  114986. step?: number);
  114987. /**
  114988. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  114989. * @param scene defines the current scene where to apply this optimization
  114990. * @param optimizer defines the current optimizer
  114991. * @returns true if everything that can be done was applied
  114992. */
  114993. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  114994. }
  114995. /**
  114996. * Defines an optimization used to increase or decrease the rendering resolution
  114997. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  114998. */
  114999. export class HardwareScalingOptimization extends SceneOptimization {
  115000. /**
  115001. * Defines the priority of this optimization (0 by default which means first in the list)
  115002. */
  115003. priority: number;
  115004. /**
  115005. * Defines the maximum scale to use (2 by default)
  115006. */
  115007. maximumScale: number;
  115008. /**
  115009. * Defines the step to use between two passes (0.5 by default)
  115010. */
  115011. step: number;
  115012. private _currentScale;
  115013. private _directionOffset;
  115014. /**
  115015. * Gets a string describing the action executed by the current optimization
  115016. * @return description string
  115017. */
  115018. getDescription(): string;
  115019. /**
  115020. * Creates the HardwareScalingOptimization object
  115021. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115022. * @param maximumScale defines the maximum scale to use (2 by default)
  115023. * @param step defines the step to use between two passes (0.5 by default)
  115024. */
  115025. constructor(
  115026. /**
  115027. * Defines the priority of this optimization (0 by default which means first in the list)
  115028. */
  115029. priority?: number,
  115030. /**
  115031. * Defines the maximum scale to use (2 by default)
  115032. */
  115033. maximumScale?: number,
  115034. /**
  115035. * Defines the step to use between two passes (0.5 by default)
  115036. */
  115037. step?: number);
  115038. /**
  115039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115040. * @param scene defines the current scene where to apply this optimization
  115041. * @param optimizer defines the current optimizer
  115042. * @returns true if everything that can be done was applied
  115043. */
  115044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115045. }
  115046. /**
  115047. * Defines an optimization used to remove shadows
  115048. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115049. */
  115050. export class ShadowsOptimization extends SceneOptimization {
  115051. /**
  115052. * Gets a string describing the action executed by the current optimization
  115053. * @return description string
  115054. */
  115055. getDescription(): string;
  115056. /**
  115057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115058. * @param scene defines the current scene where to apply this optimization
  115059. * @param optimizer defines the current optimizer
  115060. * @returns true if everything that can be done was applied
  115061. */
  115062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115063. }
  115064. /**
  115065. * Defines an optimization used to turn post-processes off
  115066. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115067. */
  115068. export class PostProcessesOptimization extends SceneOptimization {
  115069. /**
  115070. * Gets a string describing the action executed by the current optimization
  115071. * @return description string
  115072. */
  115073. getDescription(): string;
  115074. /**
  115075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115076. * @param scene defines the current scene where to apply this optimization
  115077. * @param optimizer defines the current optimizer
  115078. * @returns true if everything that can be done was applied
  115079. */
  115080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115081. }
  115082. /**
  115083. * Defines an optimization used to turn lens flares off
  115084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115085. */
  115086. export class LensFlaresOptimization extends SceneOptimization {
  115087. /**
  115088. * Gets a string describing the action executed by the current optimization
  115089. * @return description string
  115090. */
  115091. getDescription(): string;
  115092. /**
  115093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115094. * @param scene defines the current scene where to apply this optimization
  115095. * @param optimizer defines the current optimizer
  115096. * @returns true if everything that can be done was applied
  115097. */
  115098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115099. }
  115100. /**
  115101. * Defines an optimization based on user defined callback.
  115102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115103. */
  115104. export class CustomOptimization extends SceneOptimization {
  115105. /**
  115106. * Callback called to apply the custom optimization.
  115107. */
  115108. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115109. /**
  115110. * Callback called to get custom description
  115111. */
  115112. onGetDescription: () => string;
  115113. /**
  115114. * Gets a string describing the action executed by the current optimization
  115115. * @returns description string
  115116. */
  115117. getDescription(): string;
  115118. /**
  115119. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115120. * @param scene defines the current scene where to apply this optimization
  115121. * @param optimizer defines the current optimizer
  115122. * @returns true if everything that can be done was applied
  115123. */
  115124. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115125. }
  115126. /**
  115127. * Defines an optimization used to turn particles off
  115128. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115129. */
  115130. export class ParticlesOptimization extends SceneOptimization {
  115131. /**
  115132. * Gets a string describing the action executed by the current optimization
  115133. * @return description string
  115134. */
  115135. getDescription(): string;
  115136. /**
  115137. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115138. * @param scene defines the current scene where to apply this optimization
  115139. * @param optimizer defines the current optimizer
  115140. * @returns true if everything that can be done was applied
  115141. */
  115142. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115143. }
  115144. /**
  115145. * Defines an optimization used to turn render targets off
  115146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115147. */
  115148. export class RenderTargetsOptimization extends SceneOptimization {
  115149. /**
  115150. * Gets a string describing the action executed by the current optimization
  115151. * @return description string
  115152. */
  115153. getDescription(): string;
  115154. /**
  115155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115156. * @param scene defines the current scene where to apply this optimization
  115157. * @param optimizer defines the current optimizer
  115158. * @returns true if everything that can be done was applied
  115159. */
  115160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115161. }
  115162. /**
  115163. * Defines an optimization used to merge meshes with compatible materials
  115164. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115165. */
  115166. export class MergeMeshesOptimization extends SceneOptimization {
  115167. private static _UpdateSelectionTree;
  115168. /**
  115169. * Gets or sets a boolean which defines if optimization octree has to be updated
  115170. */
  115171. /**
  115172. * Gets or sets a boolean which defines if optimization octree has to be updated
  115173. */
  115174. static UpdateSelectionTree: boolean;
  115175. /**
  115176. * Gets a string describing the action executed by the current optimization
  115177. * @return description string
  115178. */
  115179. getDescription(): string;
  115180. private _canBeMerged;
  115181. /**
  115182. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115183. * @param scene defines the current scene where to apply this optimization
  115184. * @param optimizer defines the current optimizer
  115185. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115186. * @returns true if everything that can be done was applied
  115187. */
  115188. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115189. }
  115190. /**
  115191. * Defines a list of options used by SceneOptimizer
  115192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115193. */
  115194. export class SceneOptimizerOptions {
  115195. /**
  115196. * Defines the target frame rate to reach (60 by default)
  115197. */
  115198. targetFrameRate: number;
  115199. /**
  115200. * Defines the interval between two checkes (2000ms by default)
  115201. */
  115202. trackerDuration: number;
  115203. /**
  115204. * Gets the list of optimizations to apply
  115205. */
  115206. optimizations: SceneOptimization[];
  115207. /**
  115208. * Creates a new list of options used by SceneOptimizer
  115209. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115210. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115211. */
  115212. constructor(
  115213. /**
  115214. * Defines the target frame rate to reach (60 by default)
  115215. */
  115216. targetFrameRate?: number,
  115217. /**
  115218. * Defines the interval between two checkes (2000ms by default)
  115219. */
  115220. trackerDuration?: number);
  115221. /**
  115222. * Add a new optimization
  115223. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115224. * @returns the current SceneOptimizerOptions
  115225. */
  115226. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115227. /**
  115228. * Add a new custom optimization
  115229. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115230. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115231. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115232. * @returns the current SceneOptimizerOptions
  115233. */
  115234. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115235. /**
  115236. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115237. * @param targetFrameRate defines the target frame rate (60 by default)
  115238. * @returns a SceneOptimizerOptions object
  115239. */
  115240. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115241. /**
  115242. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115243. * @param targetFrameRate defines the target frame rate (60 by default)
  115244. * @returns a SceneOptimizerOptions object
  115245. */
  115246. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115247. /**
  115248. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115249. * @param targetFrameRate defines the target frame rate (60 by default)
  115250. * @returns a SceneOptimizerOptions object
  115251. */
  115252. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115253. }
  115254. /**
  115255. * Class used to run optimizations in order to reach a target frame rate
  115256. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115257. */
  115258. export class SceneOptimizer implements IDisposable {
  115259. private _isRunning;
  115260. private _options;
  115261. private _scene;
  115262. private _currentPriorityLevel;
  115263. private _targetFrameRate;
  115264. private _trackerDuration;
  115265. private _currentFrameRate;
  115266. private _sceneDisposeObserver;
  115267. private _improvementMode;
  115268. /**
  115269. * Defines an observable called when the optimizer reaches the target frame rate
  115270. */
  115271. onSuccessObservable: Observable<SceneOptimizer>;
  115272. /**
  115273. * Defines an observable called when the optimizer enables an optimization
  115274. */
  115275. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115276. /**
  115277. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115278. */
  115279. onFailureObservable: Observable<SceneOptimizer>;
  115280. /**
  115281. * Gets a boolean indicating if the optimizer is in improvement mode
  115282. */
  115283. readonly isInImprovementMode: boolean;
  115284. /**
  115285. * Gets the current priority level (0 at start)
  115286. */
  115287. readonly currentPriorityLevel: number;
  115288. /**
  115289. * Gets the current frame rate checked by the SceneOptimizer
  115290. */
  115291. readonly currentFrameRate: number;
  115292. /**
  115293. * Gets or sets the current target frame rate (60 by default)
  115294. */
  115295. /**
  115296. * Gets or sets the current target frame rate (60 by default)
  115297. */
  115298. targetFrameRate: number;
  115299. /**
  115300. * Gets or sets the current interval between two checks (every 2000ms by default)
  115301. */
  115302. /**
  115303. * Gets or sets the current interval between two checks (every 2000ms by default)
  115304. */
  115305. trackerDuration: number;
  115306. /**
  115307. * Gets the list of active optimizations
  115308. */
  115309. readonly optimizations: SceneOptimization[];
  115310. /**
  115311. * Creates a new SceneOptimizer
  115312. * @param scene defines the scene to work on
  115313. * @param options defines the options to use with the SceneOptimizer
  115314. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115315. * @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)
  115316. */
  115317. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115318. /**
  115319. * Stops the current optimizer
  115320. */
  115321. stop(): void;
  115322. /**
  115323. * Reset the optimizer to initial step (current priority level = 0)
  115324. */
  115325. reset(): void;
  115326. /**
  115327. * Start the optimizer. By default it will try to reach a specific framerate
  115328. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115329. */
  115330. start(): void;
  115331. private _checkCurrentState;
  115332. /**
  115333. * Release all resources
  115334. */
  115335. dispose(): void;
  115336. /**
  115337. * Helper function to create a SceneOptimizer with one single line of code
  115338. * @param scene defines the scene to work on
  115339. * @param options defines the options to use with the SceneOptimizer
  115340. * @param onSuccess defines a callback to call on success
  115341. * @param onFailure defines a callback to call on failure
  115342. * @returns the new SceneOptimizer object
  115343. */
  115344. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115345. }
  115346. }
  115347. declare module BABYLON {
  115348. /**
  115349. * Class used to serialize a scene into a string
  115350. */
  115351. export class SceneSerializer {
  115352. /**
  115353. * Clear cache used by a previous serialization
  115354. */
  115355. static ClearCache(): void;
  115356. /**
  115357. * Serialize a scene into a JSON compatible object
  115358. * @param scene defines the scene to serialize
  115359. * @returns a JSON compatible object
  115360. */
  115361. static Serialize(scene: Scene): any;
  115362. /**
  115363. * Serialize a mesh into a JSON compatible object
  115364. * @param toSerialize defines the mesh to serialize
  115365. * @param withParents defines if parents must be serialized as well
  115366. * @param withChildren defines if children must be serialized as well
  115367. * @returns a JSON compatible object
  115368. */
  115369. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115370. }
  115371. }
  115372. declare module BABYLON {
  115373. /**
  115374. * Class used to host texture specific utilities
  115375. */
  115376. export class TextureTools {
  115377. /**
  115378. * Uses the GPU to create a copy texture rescaled at a given size
  115379. * @param texture Texture to copy from
  115380. * @param width defines the desired width
  115381. * @param height defines the desired height
  115382. * @param useBilinearMode defines if bilinear mode has to be used
  115383. * @return the generated texture
  115384. */
  115385. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115386. }
  115387. }
  115388. declare module BABYLON {
  115389. /**
  115390. * This represents the different options avilable for the video capture.
  115391. */
  115392. export interface VideoRecorderOptions {
  115393. /** Defines the mime type of the video */
  115394. mimeType: string;
  115395. /** Defines the video the video should be recorded at */
  115396. fps: number;
  115397. /** Defines the chunk size for the recording data */
  115398. recordChunckSize: number;
  115399. /** The audio tracks to attach to the record */
  115400. audioTracks?: MediaStreamTrack[];
  115401. }
  115402. /**
  115403. * This can helps recording videos from BabylonJS.
  115404. * This is based on the available WebRTC functionalities of the browser.
  115405. *
  115406. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115407. */
  115408. export class VideoRecorder {
  115409. private static readonly _defaultOptions;
  115410. /**
  115411. * Returns wehther or not the VideoRecorder is available in your browser.
  115412. * @param engine Defines the Babylon Engine to check the support for
  115413. * @returns true if supported otherwise false
  115414. */
  115415. static IsSupported(engine: Engine): boolean;
  115416. private readonly _options;
  115417. private _canvas;
  115418. private _mediaRecorder;
  115419. private _recordedChunks;
  115420. private _fileName;
  115421. private _resolve;
  115422. private _reject;
  115423. /**
  115424. * True wether a recording is already in progress.
  115425. */
  115426. readonly isRecording: boolean;
  115427. /**
  115428. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115429. * a video file.
  115430. * @param engine Defines the BabylonJS Engine you wish to record
  115431. * @param options Defines options that can be used to customized the capture
  115432. */
  115433. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115434. /**
  115435. * Stops the current recording before the default capture timeout passed in the startRecording
  115436. * functions.
  115437. */
  115438. stopRecording(): void;
  115439. /**
  115440. * Starts recording the canvas for a max duration specified in parameters.
  115441. * @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.
  115442. * @param maxDuration Defines the maximum recording time in seconds.
  115443. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115444. * @return a promise callback at the end of the recording with the video data in Blob.
  115445. */
  115446. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115447. /**
  115448. * Releases internal resources used during the recording.
  115449. */
  115450. dispose(): void;
  115451. private _handleDataAvailable;
  115452. private _handleError;
  115453. private _handleStop;
  115454. }
  115455. }
  115456. declare module BABYLON {
  115457. /**
  115458. * Class containing a set of static utilities functions for screenshots
  115459. */
  115460. export class ScreenshotTools {
  115461. /**
  115462. * Captures a screenshot of the current rendering
  115463. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115464. * @param engine defines the rendering engine
  115465. * @param camera defines the source camera
  115466. * @param size This parameter can be set to a single number or to an object with the
  115467. * following (optional) properties: precision, width, height. If a single number is passed,
  115468. * it will be used for both width and height. If an object is passed, the screenshot size
  115469. * will be derived from the parameters. The precision property is a multiplier allowing
  115470. * rendering at a higher or lower resolution
  115471. * @param successCallback defines the callback receives a single parameter which contains the
  115472. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115473. * src parameter of an <img> to display it
  115474. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115475. * Check your browser for supported MIME types
  115476. */
  115477. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115478. /**
  115479. * Generates an image screenshot from the specified camera.
  115480. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115481. * @param engine The engine to use for rendering
  115482. * @param camera The camera to use for rendering
  115483. * @param size This parameter can be set to a single number or to an object with the
  115484. * following (optional) properties: precision, width, height. If a single number is passed,
  115485. * it will be used for both width and height. If an object is passed, the screenshot size
  115486. * will be derived from the parameters. The precision property is a multiplier allowing
  115487. * rendering at a higher or lower resolution
  115488. * @param successCallback The callback receives a single parameter which contains the
  115489. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115490. * src parameter of an <img> to display it
  115491. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115492. * Check your browser for supported MIME types
  115493. * @param samples Texture samples (default: 1)
  115494. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115495. * @param fileName A name for for the downloaded file.
  115496. */
  115497. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115498. }
  115499. }
  115500. declare module BABYLON {
  115501. /**
  115502. * A cursor which tracks a point on a path
  115503. */
  115504. export class PathCursor {
  115505. private path;
  115506. /**
  115507. * Stores path cursor callbacks for when an onchange event is triggered
  115508. */
  115509. private _onchange;
  115510. /**
  115511. * The value of the path cursor
  115512. */
  115513. value: number;
  115514. /**
  115515. * The animation array of the path cursor
  115516. */
  115517. animations: Animation[];
  115518. /**
  115519. * Initializes the path cursor
  115520. * @param path The path to track
  115521. */
  115522. constructor(path: Path2);
  115523. /**
  115524. * Gets the cursor point on the path
  115525. * @returns A point on the path cursor at the cursor location
  115526. */
  115527. getPoint(): Vector3;
  115528. /**
  115529. * Moves the cursor ahead by the step amount
  115530. * @param step The amount to move the cursor forward
  115531. * @returns This path cursor
  115532. */
  115533. moveAhead(step?: number): PathCursor;
  115534. /**
  115535. * Moves the cursor behind by the step amount
  115536. * @param step The amount to move the cursor back
  115537. * @returns This path cursor
  115538. */
  115539. moveBack(step?: number): PathCursor;
  115540. /**
  115541. * Moves the cursor by the step amount
  115542. * If the step amount is greater than one, an exception is thrown
  115543. * @param step The amount to move the cursor
  115544. * @returns This path cursor
  115545. */
  115546. move(step: number): PathCursor;
  115547. /**
  115548. * Ensures that the value is limited between zero and one
  115549. * @returns This path cursor
  115550. */
  115551. private ensureLimits;
  115552. /**
  115553. * Runs onchange callbacks on change (used by the animation engine)
  115554. * @returns This path cursor
  115555. */
  115556. private raiseOnChange;
  115557. /**
  115558. * Executes a function on change
  115559. * @param f A path cursor onchange callback
  115560. * @returns This path cursor
  115561. */
  115562. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115563. }
  115564. }
  115565. declare module BABYLON {
  115566. /** @hidden */
  115567. export var blurPixelShader: {
  115568. name: string;
  115569. shader: string;
  115570. };
  115571. }
  115572. declare module BABYLON {
  115573. /** @hidden */
  115574. export var bones300Declaration: {
  115575. name: string;
  115576. shader: string;
  115577. };
  115578. }
  115579. declare module BABYLON {
  115580. /** @hidden */
  115581. export var instances300Declaration: {
  115582. name: string;
  115583. shader: string;
  115584. };
  115585. }
  115586. declare module BABYLON {
  115587. /** @hidden */
  115588. export var pointCloudVertexDeclaration: {
  115589. name: string;
  115590. shader: string;
  115591. };
  115592. }
  115593. // Mixins
  115594. interface Window {
  115595. mozIndexedDB: IDBFactory;
  115596. webkitIndexedDB: IDBFactory;
  115597. msIndexedDB: IDBFactory;
  115598. webkitURL: typeof URL;
  115599. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115600. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115601. WebGLRenderingContext: WebGLRenderingContext;
  115602. MSGesture: MSGesture;
  115603. CANNON: any;
  115604. AudioContext: AudioContext;
  115605. webkitAudioContext: AudioContext;
  115606. PointerEvent: any;
  115607. Math: Math;
  115608. Uint8Array: Uint8ArrayConstructor;
  115609. Float32Array: Float32ArrayConstructor;
  115610. mozURL: typeof URL;
  115611. msURL: typeof URL;
  115612. VRFrameData: any; // WebVR, from specs 1.1
  115613. DracoDecoderModule: any;
  115614. setImmediate(handler: (...args: any[]) => void): number;
  115615. }
  115616. interface HTMLCanvasElement {
  115617. requestPointerLock(): void;
  115618. msRequestPointerLock?(): void;
  115619. mozRequestPointerLock?(): void;
  115620. webkitRequestPointerLock?(): void;
  115621. /** Track wether a record is in progress */
  115622. isRecording: boolean;
  115623. /** Capture Stream method defined by some browsers */
  115624. captureStream(fps?: number): MediaStream;
  115625. }
  115626. interface CanvasRenderingContext2D {
  115627. msImageSmoothingEnabled: boolean;
  115628. }
  115629. interface MouseEvent {
  115630. mozMovementX: number;
  115631. mozMovementY: number;
  115632. webkitMovementX: number;
  115633. webkitMovementY: number;
  115634. msMovementX: number;
  115635. msMovementY: number;
  115636. }
  115637. interface Navigator {
  115638. mozGetVRDevices: (any: any) => any;
  115639. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115640. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115641. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115642. webkitGetGamepads(): Gamepad[];
  115643. msGetGamepads(): Gamepad[];
  115644. webkitGamepads(): Gamepad[];
  115645. }
  115646. interface HTMLVideoElement {
  115647. mozSrcObject: any;
  115648. }
  115649. interface Math {
  115650. fround(x: number): number;
  115651. imul(a: number, b: number): number;
  115652. }
  115653. interface WebGLProgram {
  115654. context?: WebGLRenderingContext;
  115655. vertexShader?: WebGLShader;
  115656. fragmentShader?: WebGLShader;
  115657. isParallelCompiled: boolean;
  115658. onCompiled?: () => void;
  115659. }
  115660. interface WebGLRenderingContext {
  115661. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115662. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115663. vertexAttribDivisor(index: number, divisor: number): void;
  115664. createVertexArray(): any;
  115665. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115666. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115667. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115668. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115669. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115670. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115671. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115672. // Queries
  115673. createQuery(): WebGLQuery;
  115674. deleteQuery(query: WebGLQuery): void;
  115675. beginQuery(target: number, query: WebGLQuery): void;
  115676. endQuery(target: number): void;
  115677. getQueryParameter(query: WebGLQuery, pname: number): any;
  115678. getQuery(target: number, pname: number): any;
  115679. MAX_SAMPLES: number;
  115680. RGBA8: number;
  115681. READ_FRAMEBUFFER: number;
  115682. DRAW_FRAMEBUFFER: number;
  115683. UNIFORM_BUFFER: number;
  115684. HALF_FLOAT_OES: number;
  115685. RGBA16F: number;
  115686. RGBA32F: number;
  115687. R32F: number;
  115688. RG32F: number;
  115689. RGB32F: number;
  115690. R16F: number;
  115691. RG16F: number;
  115692. RGB16F: number;
  115693. RED: number;
  115694. RG: number;
  115695. R8: number;
  115696. RG8: number;
  115697. UNSIGNED_INT_24_8: number;
  115698. DEPTH24_STENCIL8: number;
  115699. /* Multiple Render Targets */
  115700. drawBuffers(buffers: number[]): void;
  115701. readBuffer(src: number): void;
  115702. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115703. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115704. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115705. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115706. // Occlusion Query
  115707. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115708. ANY_SAMPLES_PASSED: number;
  115709. QUERY_RESULT_AVAILABLE: number;
  115710. QUERY_RESULT: number;
  115711. }
  115712. interface WebGLBuffer {
  115713. references: number;
  115714. capacity: number;
  115715. is32Bits: boolean;
  115716. }
  115717. interface WebGLProgram {
  115718. transformFeedback?: WebGLTransformFeedback | null;
  115719. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115720. }
  115721. interface EXT_disjoint_timer_query {
  115722. QUERY_COUNTER_BITS_EXT: number;
  115723. TIME_ELAPSED_EXT: number;
  115724. TIMESTAMP_EXT: number;
  115725. GPU_DISJOINT_EXT: number;
  115726. QUERY_RESULT_EXT: number;
  115727. QUERY_RESULT_AVAILABLE_EXT: number;
  115728. queryCounterEXT(query: WebGLQuery, target: number): void;
  115729. createQueryEXT(): WebGLQuery;
  115730. beginQueryEXT(target: number, query: WebGLQuery): void;
  115731. endQueryEXT(target: number): void;
  115732. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115733. deleteQueryEXT(query: WebGLQuery): void;
  115734. }
  115735. interface WebGLUniformLocation {
  115736. _currentState: any;
  115737. }
  115738. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  115739. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  115740. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  115741. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115742. interface WebGLRenderingContext {
  115743. readonly RASTERIZER_DISCARD: number;
  115744. readonly DEPTH_COMPONENT24: number;
  115745. readonly TEXTURE_3D: number;
  115746. readonly TEXTURE_2D_ARRAY: number;
  115747. readonly TEXTURE_COMPARE_FUNC: number;
  115748. readonly TEXTURE_COMPARE_MODE: number;
  115749. readonly COMPARE_REF_TO_TEXTURE: number;
  115750. readonly TEXTURE_WRAP_R: number;
  115751. readonly HALF_FLOAT: number;
  115752. readonly RGB8: number;
  115753. readonly RED_INTEGER: number;
  115754. readonly RG_INTEGER: number;
  115755. readonly RGB_INTEGER: number;
  115756. readonly RGBA_INTEGER: number;
  115757. readonly R8_SNORM: number;
  115758. readonly RG8_SNORM: number;
  115759. readonly RGB8_SNORM: number;
  115760. readonly RGBA8_SNORM: number;
  115761. readonly R8I: number;
  115762. readonly RG8I: number;
  115763. readonly RGB8I: number;
  115764. readonly RGBA8I: number;
  115765. readonly R8UI: number;
  115766. readonly RG8UI: number;
  115767. readonly RGB8UI: number;
  115768. readonly RGBA8UI: number;
  115769. readonly R16I: number;
  115770. readonly RG16I: number;
  115771. readonly RGB16I: number;
  115772. readonly RGBA16I: number;
  115773. readonly R16UI: number;
  115774. readonly RG16UI: number;
  115775. readonly RGB16UI: number;
  115776. readonly RGBA16UI: number;
  115777. readonly R32I: number;
  115778. readonly RG32I: number;
  115779. readonly RGB32I: number;
  115780. readonly RGBA32I: number;
  115781. readonly R32UI: number;
  115782. readonly RG32UI: number;
  115783. readonly RGB32UI: number;
  115784. readonly RGBA32UI: number;
  115785. readonly RGB10_A2UI: number;
  115786. readonly R11F_G11F_B10F: number;
  115787. readonly RGB9_E5: number;
  115788. readonly RGB10_A2: number;
  115789. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  115790. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  115791. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  115792. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  115793. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  115794. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  115795. 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;
  115796. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  115797. readonly TRANSFORM_FEEDBACK: number;
  115798. readonly INTERLEAVED_ATTRIBS: number;
  115799. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  115800. createTransformFeedback(): WebGLTransformFeedback;
  115801. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  115802. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  115803. beginTransformFeedback(primitiveMode: number): void;
  115804. endTransformFeedback(): void;
  115805. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  115806. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115807. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115808. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  115809. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  115810. }
  115811. interface ImageBitmap {
  115812. readonly width: number;
  115813. readonly height: number;
  115814. close(): void;
  115815. }
  115816. interface WebGLQuery extends WebGLObject {
  115817. }
  115818. declare var WebGLQuery: {
  115819. prototype: WebGLQuery;
  115820. new(): WebGLQuery;
  115821. };
  115822. interface WebGLSampler extends WebGLObject {
  115823. }
  115824. declare var WebGLSampler: {
  115825. prototype: WebGLSampler;
  115826. new(): WebGLSampler;
  115827. };
  115828. interface WebGLSync extends WebGLObject {
  115829. }
  115830. declare var WebGLSync: {
  115831. prototype: WebGLSync;
  115832. new(): WebGLSync;
  115833. };
  115834. interface WebGLTransformFeedback extends WebGLObject {
  115835. }
  115836. declare var WebGLTransformFeedback: {
  115837. prototype: WebGLTransformFeedback;
  115838. new(): WebGLTransformFeedback;
  115839. };
  115840. interface WebGLVertexArrayObject extends WebGLObject {
  115841. }
  115842. declare var WebGLVertexArrayObject: {
  115843. prototype: WebGLVertexArrayObject;
  115844. new(): WebGLVertexArrayObject;
  115845. };
  115846. // Type definitions for WebVR API
  115847. // Project: https://w3c.github.io/webvr/
  115848. // Definitions by: six a <https://github.com/lostfictions>
  115849. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  115850. interface VRDisplay extends EventTarget {
  115851. /**
  115852. * Dictionary of capabilities describing the VRDisplay.
  115853. */
  115854. readonly capabilities: VRDisplayCapabilities;
  115855. /**
  115856. * z-depth defining the far plane of the eye view frustum
  115857. * enables mapping of values in the render target depth
  115858. * attachment to scene coordinates. Initially set to 10000.0.
  115859. */
  115860. depthFar: number;
  115861. /**
  115862. * z-depth defining the near plane of the eye view frustum
  115863. * enables mapping of values in the render target depth
  115864. * attachment to scene coordinates. Initially set to 0.01.
  115865. */
  115866. depthNear: number;
  115867. /**
  115868. * An identifier for this distinct VRDisplay. Used as an
  115869. * association point in the Gamepad API.
  115870. */
  115871. readonly displayId: number;
  115872. /**
  115873. * A display name, a user-readable name identifying it.
  115874. */
  115875. readonly displayName: string;
  115876. readonly isConnected: boolean;
  115877. readonly isPresenting: boolean;
  115878. /**
  115879. * If this VRDisplay supports room-scale experiences, the optional
  115880. * stage attribute contains details on the room-scale parameters.
  115881. */
  115882. readonly stageParameters: VRStageParameters | null;
  115883. /**
  115884. * Passing the value returned by `requestAnimationFrame` to
  115885. * `cancelAnimationFrame` will unregister the callback.
  115886. * @param handle Define the hanle of the request to cancel
  115887. */
  115888. cancelAnimationFrame(handle: number): void;
  115889. /**
  115890. * Stops presenting to the VRDisplay.
  115891. * @returns a promise to know when it stopped
  115892. */
  115893. exitPresent(): Promise<void>;
  115894. /**
  115895. * Return the current VREyeParameters for the given eye.
  115896. * @param whichEye Define the eye we want the parameter for
  115897. * @returns the eye parameters
  115898. */
  115899. getEyeParameters(whichEye: string): VREyeParameters;
  115900. /**
  115901. * Populates the passed VRFrameData with the information required to render
  115902. * the current frame.
  115903. * @param frameData Define the data structure to populate
  115904. * @returns true if ok otherwise false
  115905. */
  115906. getFrameData(frameData: VRFrameData): boolean;
  115907. /**
  115908. * Get the layers currently being presented.
  115909. * @returns the list of VR layers
  115910. */
  115911. getLayers(): VRLayer[];
  115912. /**
  115913. * Return a VRPose containing the future predicted pose of the VRDisplay
  115914. * when the current frame will be presented. The value returned will not
  115915. * change until JavaScript has returned control to the browser.
  115916. *
  115917. * The VRPose will contain the position, orientation, velocity,
  115918. * and acceleration of each of these properties.
  115919. * @returns the pose object
  115920. */
  115921. getPose(): VRPose;
  115922. /**
  115923. * Return the current instantaneous pose of the VRDisplay, with no
  115924. * prediction applied.
  115925. * @returns the current instantaneous pose
  115926. */
  115927. getImmediatePose(): VRPose;
  115928. /**
  115929. * The callback passed to `requestAnimationFrame` will be called
  115930. * any time a new frame should be rendered. When the VRDisplay is
  115931. * presenting the callback will be called at the native refresh
  115932. * rate of the HMD. When not presenting this function acts
  115933. * identically to how window.requestAnimationFrame acts. Content should
  115934. * make no assumptions of frame rate or vsync behavior as the HMD runs
  115935. * asynchronously from other displays and at differing refresh rates.
  115936. * @param callback Define the eaction to run next frame
  115937. * @returns the request handle it
  115938. */
  115939. requestAnimationFrame(callback: FrameRequestCallback): number;
  115940. /**
  115941. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  115942. * Repeat calls while already presenting will update the VRLayers being displayed.
  115943. * @param layers Define the list of layer to present
  115944. * @returns a promise to know when the request has been fulfilled
  115945. */
  115946. requestPresent(layers: VRLayer[]): Promise<void>;
  115947. /**
  115948. * Reset the pose for this display, treating its current position and
  115949. * orientation as the "origin/zero" values. VRPose.position,
  115950. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  115951. * updated when calling resetPose(). This should be called in only
  115952. * sitting-space experiences.
  115953. */
  115954. resetPose(): void;
  115955. /**
  115956. * The VRLayer provided to the VRDisplay will be captured and presented
  115957. * in the HMD. Calling this function has the same effect on the source
  115958. * canvas as any other operation that uses its source image, and canvases
  115959. * created without preserveDrawingBuffer set to true will be cleared.
  115960. * @param pose Define the pose to submit
  115961. */
  115962. submitFrame(pose?: VRPose): void;
  115963. }
  115964. declare var VRDisplay: {
  115965. prototype: VRDisplay;
  115966. new(): VRDisplay;
  115967. };
  115968. interface VRLayer {
  115969. leftBounds?: number[] | Float32Array | null;
  115970. rightBounds?: number[] | Float32Array | null;
  115971. source?: HTMLCanvasElement | null;
  115972. }
  115973. interface VRDisplayCapabilities {
  115974. readonly canPresent: boolean;
  115975. readonly hasExternalDisplay: boolean;
  115976. readonly hasOrientation: boolean;
  115977. readonly hasPosition: boolean;
  115978. readonly maxLayers: number;
  115979. }
  115980. interface VREyeParameters {
  115981. /** @deprecated */
  115982. readonly fieldOfView: VRFieldOfView;
  115983. readonly offset: Float32Array;
  115984. readonly renderHeight: number;
  115985. readonly renderWidth: number;
  115986. }
  115987. interface VRFieldOfView {
  115988. readonly downDegrees: number;
  115989. readonly leftDegrees: number;
  115990. readonly rightDegrees: number;
  115991. readonly upDegrees: number;
  115992. }
  115993. interface VRFrameData {
  115994. readonly leftProjectionMatrix: Float32Array;
  115995. readonly leftViewMatrix: Float32Array;
  115996. readonly pose: VRPose;
  115997. readonly rightProjectionMatrix: Float32Array;
  115998. readonly rightViewMatrix: Float32Array;
  115999. readonly timestamp: number;
  116000. }
  116001. interface VRPose {
  116002. readonly angularAcceleration: Float32Array | null;
  116003. readonly angularVelocity: Float32Array | null;
  116004. readonly linearAcceleration: Float32Array | null;
  116005. readonly linearVelocity: Float32Array | null;
  116006. readonly orientation: Float32Array | null;
  116007. readonly position: Float32Array | null;
  116008. readonly timestamp: number;
  116009. }
  116010. interface VRStageParameters {
  116011. sittingToStandingTransform?: Float32Array;
  116012. sizeX?: number;
  116013. sizeY?: number;
  116014. }
  116015. interface Navigator {
  116016. getVRDisplays(): Promise<VRDisplay[]>;
  116017. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116018. }
  116019. interface Window {
  116020. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116021. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116022. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116023. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116024. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116025. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116026. }
  116027. interface Gamepad {
  116028. readonly displayId: number;
  116029. }
  116030. interface XRDevice {
  116031. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116032. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116033. }
  116034. interface XRSession {
  116035. getInputSources(): Array<any>;
  116036. baseLayer: XRWebGLLayer;
  116037. requestFrameOfReference(type: string): Promise<void>;
  116038. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116039. end(): Promise<void>;
  116040. requestAnimationFrame: Function;
  116041. addEventListener: Function;
  116042. }
  116043. interface XRSessionCreationOptions {
  116044. outputContext?: WebGLRenderingContext | null;
  116045. immersive?: boolean;
  116046. environmentIntegration?: boolean;
  116047. }
  116048. interface XRLayer {
  116049. getViewport: Function;
  116050. framebufferWidth: number;
  116051. framebufferHeight: number;
  116052. }
  116053. interface XRView {
  116054. projectionMatrix: Float32Array;
  116055. }
  116056. interface XRFrame {
  116057. getDevicePose: Function;
  116058. getInputPose: Function;
  116059. views: Array<XRView>;
  116060. baseLayer: XRLayer;
  116061. }
  116062. interface XRFrameOfReference {
  116063. }
  116064. interface XRWebGLLayer extends XRLayer {
  116065. framebuffer: WebGLFramebuffer;
  116066. }
  116067. declare var XRWebGLLayer: {
  116068. prototype: XRWebGLLayer;
  116069. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116070. };